无法在导航栏上共享显示putExtra

时间:2018-10-24 09:08:42

标签: java android android-intent

我在导航栏中有共享代码,并且我提取了程序包和文本,但未显示我的一条putExtra行。

else if (id == R.id.nav_share) {
            try {
                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("text/plain");
                i.putExtra(Intent.EXTRA_SUBJECT, " Hey Download this App Called\n App name");
                String sAux = " to Improve your Life's....... \nAt least One Time Try This\n";
                sAux = sAux + "https://play.google.com/store/apps/details?id=com.example.kishorsinh.app \n\n";
                i.putExtra(Intent.EXTRA_TEXT, sAux);
                startActivity(Intent.createChooser(i, "Choose one"));
            } catch(Exception e) {
                //e.toString();
            }
        } 

我已在应用中使用此代码并共享,然后仅显示。...

改善生活.... 至少一次尝试 https://play.google.com/store/apps/details?id=com.example.kishorsinh.app

有人可以建议我出什么问题吗?它不反映putExtra字段。

1 个答案:

答案 0 :(得分:0)

我更改了整个程序,可能会解决其他问题,对我来说很完美

   try {
                    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
                    final String appPackageName = getApplicationContext().getPackageName();
                    String strAppLink = "https://play.google.com/store/apps/details?id=" + appPackageName;
                    shareIntent.setType("text/plain");
                    String shareBody = strAppLink;
                    String shareSub = "Hey Download this App Called\n Appname ........\nAt least One Time Try This\n";
                    shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, shareSub);
                    shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
                    startActivity(Intent.createChooser(shareIntent, "Share using"));
                }
                catch (ActivityNotFoundException e)
                {

                }