2016-05-12 3 views
0

アンドロイドに「アプリを共有」機能を実装するにはどうすればよいですか?私は多くのウェブサイトを見ましたが、どのようにファイル、マルチメディアなどを共有するかを示しています。しかし、アプリケーション自体を共有するための適切なコードはありません。誰でも助けてくれますか?アンドロイドでアプリの機能を共有する

答えて

4

あなたは、コードの下にハードコーディングするのではなく、BuildConfig.APPLICATION_ID

try 
    { Intent i = new Intent(Intent.ACTION_SEND); 
     i.setType("text/plain"); 
     i.putExtra(Intent.EXTRA_SUBJECT, "My application name"); 
     String sAux = "\nLet me recommend you this application\n\n"; 
     sAux = sAux + "https://play.google.com/store/apps/details?id=Orion.Soft \n\n"; 
     i.putExtra(Intent.EXTRA_TEXT, sAux); 
     startActivity(Intent.createChooser(i, "choose one")); 
    } 
    catch(Exception e) 
    { //e.toString(); 
    } 
+0

より良い使用を使用することができます。また、ここでの選択のための本当の必要はありません – ligi

+0

@Krishnaありがとうたくさん – PersianBlue

0
You can try the below code for sharing your application : 
try { 
      Intent i = new Intent(Intent.ACTION_SEND); 
      i.setType("text/plain"); 
      i.putExtra(Intent.EXTRA_SUBJECT, "Your app name"); 
      String s = "\n Your app recommendation text here\n\n"; 
      s = s + "Your string to mention here(may be playstore url)"; 
      i.putExtra(Intent.EXTRA_TEXT, sAux); 
      mActivity.startActivity(Intent.createChooser(i, "choose to share")); 
     } catch(Exception e) { 
      //e.toString(); 
      e.printStackTrace(); 
     } 
関連する問題