2017-03-12 15 views
3

FirebaseでAndroidのinstagramクローンアプリを構築しています。 Facebook、メール、WhatsAppなどでストーリーのコンテンツを共有するためのソーシャルメディア共有ボタンをアプリで使用できるようにしましたが、それについてはわからない。AndroidのFirebaseからソーシャルメディア共有ロジックを追加する

私が試したものを見てみましょう:

 

    public class InstacloneApp extends AppCompatActivity { 

    private RelativeLayout relativeLayout; 

    private ImageView postCoverImg, userPhotoUrl; 
    private TextView post_Title, post_Descpn, post_Author, postDate; 

    private Button commentsBtn; 
    private FloatingActionButton shareFAB; 

    private String post_details = null; 
    private FirebaseAuth mAuth; 
    private DatabaseReference postRef; 

    private Context mCtx = this; 
    private String uid_post = null; 

    private ScrollView scrollView; 
    private Toolbar toolbar; 

    @Override 
    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); 
     toolbar = (Toolbar) findViewById(R.id.toolbar); 

     toolbar.setTitle(""); 
     setSupportActionBar(toolbar); 

     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); 
     commentsBtn = (Button) findViewById(R.id.commentsBtn); 

     mAuth = FirebaseAuth.getInstance(); 

     postRef = FirebaseDatabase.getInstance().getReference().child("Blog").child("All_Posts"); 
     postRef.keepSynced(true); 

     postRef.child(post_details.toString()).addValueEventListener(new ValueEventListener() { // this is to retrieve and view the blog post data 
      @Override 
      public void onDataChange(DataSnapshot dataSnapshot) { 

       String title_post = (String) dataSnapshot.child("postTitle").getValue(); 
       String desc_post = (String) dataSnapshot.child("full_postDesc").getValue(); 
       String backdrop_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); 

      } 

      @Override 
      public void onCancelled(DatabaseError databaseError) { 

      } 
     }); 

     shareFAB.setOnClickListener(new View.OnClickListener() { // my implemented share action 
      @Override 
      public void onClick(View view) { 

       String content = post_details; 

       Intent shareIntent = new Intent(); 
       shareIntent.setAction(Intent.ACTION_SEND); 
       shareIntent.setType("*/*"); 
       shareIntent.putExtra(Intent.EXTRA_TEXT,content); 
       startActivity(Intent.createChooser(shareIntent,"Share With")); 

      } 
     }); 

答えて

1

あなたはポストのコンテンツを共有するので、からあなた を変更してみてください:に

intent.setType("*/*"); 

intent.setType("text/plain"); 
関連する問題