我有一个重要的问题,我需要解决它 我需要每天通过firebase数据库发送实时消息和图像,我需要每天更新主题但我的问题是(图片不会显示在应用程序中,没有任何反应)你能不能帮我...
这是代码
import android.database.Cursor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.view.View;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
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 android.webkit.MimeTypeMap;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.OnProgressListener;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import static android.R.attr.data;
public class MainActivity extends AppCompatActivity {
TextView Latestone,Msgone;
ImageView Image1;
Uri ImaUri;
URL ImaUrl;
FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
DatabaseReference mRootReference = firebaseDatabase.getReference();
DatabaseReference aKidRefernece = firebaseDatabase.getReference("latesttitle1");
DatabaseReference aChildReference = mRootReference.child("latestmsg1");
DatabaseReference bKidRefernece = firebaseDatabase.getReference("image1");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Latestone = (TextView) findViewById(R.id.latest_title);
Msgone = (TextView) findViewById(R.id.latest_msg);
Image1 = (ImageView) findViewById(R.id.image1);
Latestone.setText("Message Body");
Msgone.setText("Message Title");
}
@Override
protected void onStart() {
super.onStart();
aChildReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String message = dataSnapshot.getValue(String.class);
Msgone.setText(message);
aKidRefernece.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String title = dataSnapshot.getValue(String.class);
Latestone.setText(title);
bKidRefernece.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String image = dataSnapshot.getValue(String.class);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}