无法使用毕加索从 firebase 检索图像
Cant retrieve image frm firebase with picasso
我的问题是当我尝试从我的 firebase 存储中获取我手动上传的图像时,imageview 上没有任何显示,没有错误没有错误代码的迹象所以我很困惑我在哪里错了任何帮助我将不胜感激将所有代码行放在细节中,但如果您需要任何特定区域的代码,请在评论中说出来,我一定会感谢您!
我的 firebase JSON 文件
dosya.co/b4bli0c77fam/projectandroid-59d11-export.json.html
这是我的主要 activity 代码
package com.example.projectandroid;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.squareup.picasso.Picasso;
public class MainActivity extends AppCompatActivity {
ImageView resim1;
ImageView resim2;
ImageView resim3;
ImageView resim4;
ImageView resim5;
Button click1;
RatingBar bar1;
RatingBar bar2;
RatingBar bar3;
RatingBar bar4;
RatingBar bar5;
private FirebaseDatabase firebaseDatabase=FirebaseDatabase.getInstance();
private DatabaseReference databaseReference=firebaseDatabase.getReference();
private DatabaseReference image1=databaseReference.child("image");
private DatabaseReference image2=databaseReference.child("image2");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(getApplicationContext(),"Resim Puanlama Uygulamasına
Hoşgeldiniz!",Toast.LENGTH_LONG).show();
resim1 = (findViewById(R.id.resim1));
resim2 = (findViewById(R.id.resim2));
resim3 = (findViewById(R.id.resim3));
resim4 = (findViewById(R.id.resim4));
resim5 = (findViewById(R.id.resim5));
click1 = (findViewById(R.id.button6));
bar1 =(findViewById(R.id.bar1));
bar2 = (findViewById(R.id.bar2));
bar3 =(findViewById(R.id.bar3));
bar4 = (findViewById(R.id.bar4));
bar5 =(findViewById(R.id.bar5));
final TextView deger = (findViewById(R.id.textView));
final TextView deger2 = (findViewById(R.id.textView2));
final TextView deger3 = (findViewById(R.id.textView3));
final TextView deger4 = (findViewById(R.id.textView4));
final TextView deger5 = (findViewById(R.id.textView5));
final Intent intent = new Intent(this,loginpage.class);
bar1.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger.setText(String.valueOf(rating));
}
});
bar2.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger2.setText(String.valueOf(rating));
}
});
bar3.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger3.setText(String.valueOf(rating));
}
});
bar4.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger4.setText(String.valueOf(rating));
}
});
bar5.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger5.setText(String.valueOf(rating));
}
});
click1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("sonuc",deger.getText().toString());
intent.putExtra("sonuc1",deger2.getText().toString());
intent.putExtra("sonuc2",deger3.getText().toString());
intent.putExtra("sonuc3",deger4.getText().toString());
intent.putExtra("sonuc4",deger5.getText().toString());
startActivity(intent);
}
});
}
@Override
protected void onStart() {
super.onStart();
image1.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String link=dataSnapshot.getValue(String.class);
Picasso.get().load(link).into(resim1);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
image2.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String link2=dataSnapshot.getValue(String.class);
Picasso.get().load(link2).into(resim2);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}'
这是我的应用程序gradle
'apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-database:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.squareup.picasso:picasso:2.71828'
}
apply plugin: 'com.google.gms.google-services'
'
项目gradle
'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
'
更改您的存储权限:来自存储规则
allow read: if true;
阅读this可能对您有所帮助
我的问题是当我尝试从我的 firebase 存储中获取我手动上传的图像时,imageview 上没有任何显示,没有错误没有错误代码的迹象所以我很困惑我在哪里错了任何帮助我将不胜感激将所有代码行放在细节中,但如果您需要任何特定区域的代码,请在评论中说出来,我一定会感谢您!
我的 firebase JSON 文件
dosya.co/b4bli0c77fam/projectandroid-59d11-export.json.html
这是我的主要 activity 代码
package com.example.projectandroid;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.squareup.picasso.Picasso;
public class MainActivity extends AppCompatActivity {
ImageView resim1;
ImageView resim2;
ImageView resim3;
ImageView resim4;
ImageView resim5;
Button click1;
RatingBar bar1;
RatingBar bar2;
RatingBar bar3;
RatingBar bar4;
RatingBar bar5;
private FirebaseDatabase firebaseDatabase=FirebaseDatabase.getInstance();
private DatabaseReference databaseReference=firebaseDatabase.getReference();
private DatabaseReference image1=databaseReference.child("image");
private DatabaseReference image2=databaseReference.child("image2");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(getApplicationContext(),"Resim Puanlama Uygulamasına
Hoşgeldiniz!",Toast.LENGTH_LONG).show();
resim1 = (findViewById(R.id.resim1));
resim2 = (findViewById(R.id.resim2));
resim3 = (findViewById(R.id.resim3));
resim4 = (findViewById(R.id.resim4));
resim5 = (findViewById(R.id.resim5));
click1 = (findViewById(R.id.button6));
bar1 =(findViewById(R.id.bar1));
bar2 = (findViewById(R.id.bar2));
bar3 =(findViewById(R.id.bar3));
bar4 = (findViewById(R.id.bar4));
bar5 =(findViewById(R.id.bar5));
final TextView deger = (findViewById(R.id.textView));
final TextView deger2 = (findViewById(R.id.textView2));
final TextView deger3 = (findViewById(R.id.textView3));
final TextView deger4 = (findViewById(R.id.textView4));
final TextView deger5 = (findViewById(R.id.textView5));
final Intent intent = new Intent(this,loginpage.class);
bar1.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger.setText(String.valueOf(rating));
}
});
bar2.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger2.setText(String.valueOf(rating));
}
});
bar3.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger3.setText(String.valueOf(rating));
}
});
bar4.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger4.setText(String.valueOf(rating));
}
});
bar5.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
deger5.setText(String.valueOf(rating));
}
});
click1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
intent.putExtra("sonuc",deger.getText().toString());
intent.putExtra("sonuc1",deger2.getText().toString());
intent.putExtra("sonuc2",deger3.getText().toString());
intent.putExtra("sonuc3",deger4.getText().toString());
intent.putExtra("sonuc4",deger5.getText().toString());
startActivity(intent);
}
});
}
@Override
protected void onStart() {
super.onStart();
image1.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String link=dataSnapshot.getValue(String.class);
Picasso.get().load(link).into(resim1);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
image2.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String link2=dataSnapshot.getValue(String.class);
Picasso.get().load(link2).into(resim2);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}'
这是我的应用程序gradle
'apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-database:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.squareup.picasso:picasso:2.71828'
}
apply plugin: 'com.google.gms.google-services'
'
项目gradle '
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
'
更改您的存储权限:来自存储规则
allow read: if true;
阅读this可能对您有所帮助