ACTION_SEND intent android

2019-06-13 16:17发布

I am trying to pass a url to a specific app using the ACTION_SEND intent, I want to by pass the chooser and just go straight to the app i desire but it doesn't seem to take the url unless i use the chooser..

    private void shareIt(){

                Intent pC = new Intent(Intent.ACTION_SEND);
                pC.setType("text/plain");
                pC.putExtra(Intent.EXTRA_TEXT, "http://www.bob.com");
                pC.setType("text/plain");
                pC.setClassName("com.sec.print.mobileprint","com.sec.print.mobileprint.UI.WebPrint");
                //startActivity(pC);

                startActivity(Intent.createChooser(pC,"Share jon"));

            }

if i comment out the last line and comment back in the line before it.. it opens the app i want bypassing the chooser, but the app opens to google instead of bob.com.. if i leave it as is.. it brings up the chooser and should i choose the app it goes to bob.com .. how can i get it to go to bob.com while bypassing the chooser?

2条回答
Melony?
2楼-- · 2019-06-13 16:50

I suspect that the Intent.setClassName method you’re calling takes an unqualified class name as its second argument (after all, why bother repeating the package name qualification?). Alternatively, you can use setClass instead.

查看更多
Root(大扎)
3楼-- · 2019-06-13 17:02

Are you sure you need to pass the URL via EXTRA_TEXT and not by pC.setData(Uri.parse("http://www.bob.com");?

查看更多
登录 后发表回答