2014-07-23 59 views

回答

2
Intent intentIN = getPackageManager().getLaunchIntentForPackage("PACKAGE NAME"); 
     if (intentIN != null) { 
      Intent shareIntentIN = new Intent(); 
      shareIntentIN.setAction(Intent.ACTION_SEND); 
      shareIntentIN.setPackage("com.instagram.android"); 
      try { 
       shareIntentIN.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), "", "I am Happy", "Share happy !"))); 
      } catch (FileNotFoundException e) { 
       e.printStackTrace(); 
      } 
      shareIntentIN.setType("image/jpeg"); 

      startActivity(shareIntentIN); 
     } else { 
      // bring user to the market to download the app. 
      // or let them choose an app? 
      intentIN = new Intent(Intent.ACTION_VIEW); 
      intentIN.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      intentIN.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.instagram.android&hl=en")); 
      startActivity(intentIN); 
     } 

请尝试this.change包名称,按您的需要。

0
Intent shareIntent = new Intent(Intent.ACTION_SEND); 
    shareIntent.setType("text/plain"); 
    shareIntent.putExtra(Intent.EXTRA_TEXT, mUrl); 
    shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mTitle); 
    startActivity(Intent.createChooser(shareIntent, "Share XXX")); 
相关问题