【发布时间】:2017-08-02 05:29:35
【问题描述】:
我正在使用 Firebase 构建一个 android instagram 克隆应用程序。我在我的应用程序中启用了社交媒体分享按钮,以便通过 Facebook、电子邮件、WhatsApp 等分享故事的内容,但不知道如何去做。
看看我的尝试:
公共类 InstacloneApp 扩展 AppCompatActivity { 私有RelativeLayoutrelativeLayout; 私有 ImageView postCoverImg, userPhotoUrl; 私有TextView post_Title,post_Descpn,post_Author,postDate; 私人按钮 cmetsBtn; 私有 FloatingActionButton shareFAB; 私人字符串 post_details = null; 私人 FirebaseAuth mAuth; 私有数据库参考 postRef; 私有上下文 mCtx = this; 私有字符串 uid_post = null; 私有 ScrollView 滚动视图; 私人工具栏工具栏; @覆盖 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_insta_clone_app); relativeLayout = (RelativeLayout) findViewById(R.id.activity_blog_posts_view); scrollView = (ScrollView) findViewById(R.id.scrollView); 工具栏 = (工具栏) findViewById(R.id.toolbar); 工具栏.setTitle(""); setSupportActionBar(工具栏); getSupportActionBar().setDisplayHomeAsUpEnabled(true); post_details = getIntent().getExtras().getString("post+key"); postCoverImg = (ImageView) findViewById(R.id.post_Backdrop); post_Title = (TextView) findViewById(R.id.post_title); post_Descpn = (TextView) findViewById(R.id.post_description_long); post_Author = (TextView) findViewById(R.id.authorTV); userPhotoUrl = (ImageView) findViewById(R.id.author_photo); postDate = (TextView) findViewById(R.id.post_date); shareFAB = (FloatingActionButton) findViewById(R.id.shareFAB); cmetsBtn = (按钮) findViewById(R.id.cmetsBtn); mAuth = FirebaseAuth.getInstance(); postRef = FirebaseDatabase.getInstance().getReference().child("Blog").child("All_Posts"); postRef.keepSynced(true); postRef.child(post_details.toString()).addValueEventListener(new ValueEventListener() { // 这是检索和查看博文数据 @覆盖 公共无效 onDataChange(DataSnapshot 数据快照){ String title_post = (String) dataSnapshot.child("postTitle").getValue(); String desc_post = (String) dataSnapshot.child("full_postDesc").getValue(); String background_post = (String) dataSnapshot.child("postImage").getValue(); String date_post = (String) dataSnapshot.child("postDate").getValue(); uid_post = (String) dataSnapshot.child("uid").getValue(); post_Title.setText(title_post); post_Descpn.setText(desc_post); postDate.setText(date_post); Glide.with(mCtx).load(backdrop_post).into(postCoverImg); } @覆盖 公共无效 onCancelled(DatabaseError databaseError) { } }); shareFAB.setOnClickListener(new View.OnClickListener() { // 我实现的分享动作 @覆盖 public void onClick(查看视图){ 字符串内容 = post_details; 意图 shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("*/*"); shareIntent.putExtra(Intent.EXTRA_TEXT,content); startActivity(Intent.createChooser(shareIntent,"分享给")); } });【问题讨论】:
标签: android firebase firebase-realtime-database media