android.content.Intent.setClassName()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(655)

本文整理了Java中android.content.Intent.setClassName()方法的一些代码示例,展示了Intent.setClassName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.setClassName()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:setClassName

Intent.setClassName介绍

暂无

代码示例

代码示例来源:origin: nickbutcher/plaid

public static void addKeepAliveExtra(Context context, Intent intent) {
  Intent keepAliveIntent = new Intent().setClassName(
      context.getPackageName(), KeepAliveService.class.getCanonicalName());
  intent.putExtra(EXTRA_CUSTOM_TABS_KEEP_ALIVE, keepAliveIntent);
}

代码示例来源:origin: stackoverflow.com

@Override
 public void onReceive(Context context, Intent intent) {
   //start activity
   Intent i = new Intent();
   i.setClassName("com.test", "com.test.MainActivity");
   i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   context.startActivity(i);
 }

代码示例来源:origin: stackoverflow.com

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setType("plain/text");
sendIntent.setData(Uri.parse("test@gmail.com"));
sendIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "test@gmail.com" });
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "test");
sendIntent.putExtra(Intent.EXTRA_TEXT, "hello. this is a message sent from my demo app :-)");
startActivity(sendIntent);

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent("com.android.vending.billing.PURCHASE");
intent.setClassName("com.android.vending",
    "com.google.android.finsky.billing.lightpurchase.LightPurchaseFlowActivity");
intent.putExtra(EXTRA_NAME, EXTRA_VALUE);
startActivityForResult(intent, 0);

代码示例来源:origin: stackoverflow.com

Intent intent=new Intent();
intent.setClassName(this,"com.mainscreen.activity1");
startActivity(intent);

代码示例来源:origin: stackoverflow.com

public void openGPlus(String profile) {
  try {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setClassName("com.google.android.apps.plus",
     "com.google.android.apps.plus.phone.UrlGatewayActivity");
    intent.putExtra("customAppUri", profile);
    startActivity(intent);
  } catch(ActivityNotFoundException e) {
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/"+profile+"/posts")));
  }
}

代码示例来源:origin: stackoverflow.com

Intent myIntent = new Intent();
myIntent.setClassName("com.name.tlc", "com.name.tlc.map_page");
myIntent.putExtra("LatValue", (int)39485000);
myIntent.putExtra("LongValue", (int)-80142777);
startActivity(myIntent);

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity");
startActivity(intent);

代码示例来源:origin: stackoverflow.com

public void shareFacebook() {
   String fullUrl = "https://m.facebook.com/sharer.php?u=..";
   try {
     Intent sharingIntent = new Intent(Intent.ACTION_SEND);
     sharingIntent.setClassName("com.facebook.katana",
         "com.facebook.katana.ShareLinkActivity");
     sharingIntent.putExtra(Intent.EXTRA_TEXT, "your title text");
     startActivity(sharingIntent);
   } catch (Exception e) {
     Intent i = new Intent(Intent.ACTION_VIEW);
     i.setData(Uri.parse(fullUrl));
     startActivity(i);
   }
 }

代码示例来源:origin: ankidroid/Anki-Android

public static void addKeepAliveExtra(Context context, Intent intent) {
  Intent keepAliveIntent = new Intent().setClassName(
      context.getPackageName(), KeepAliveService.class.getCanonicalName());
  intent.putExtra(EXTRA_CUSTOM_TABS_KEEP_ALIVE, keepAliveIntent);
}

代码示例来源:origin: stackoverflow.com

Intent i = new Intent();
i.setClassName("com.WAPP",
        "com.WAPP.SetLocation.setLocationActivity");
startActivity(i);

代码示例来源:origin: stackoverflow.com

try
{
  // Check if the Twitter app is installed on the phone.
  getPackageManager().getPackageInfo("com.twitter.android", 0);

  Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setClassName("com.twitter.android", "com.twitter.android.ProfileActivity");
  // Don't forget to put the "L" at the end of the id.
  intent.putExtra("user_id", 01234567L);
  startActivity(intent);
}
catch (NameNotFoundException e)
{
  // If Twitter app is not installed, start browser.
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/AndroTesteur")));
}

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent("com.android.camera.action.CROP");  
intent.setClassName("com.android.camera", "com.android.camera.CropImage");  
File file = new File(filePath);  
Uri uri = Uri.fromFile(file);  
intent.setData(uri);  
intent.putExtra("crop", "true");  
intent.putExtra("aspectX", 1);  
intent.putExtra("aspectY", 1);  
intent.putExtra("outputX", 96);  
intent.putExtra("outputY", 96);  
intent.putExtra("noFaceDetection", true);  
intent.putExtra("return-data", true);                                  
startActivityForResult(intent, REQUEST_CROP_ICON);

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent();
 intent.setClassName(resolveInfo.activityInfo.applicationInfo.packageName,
     resolveInfo.activityInfo.name);
 startActivity(intent);

代码示例来源:origin: stackoverflow.com

Intent tweetIntent = new Intent(Intent.ACTION_SEND);
tweetIntent.putExtra(Intent.EXTRA_TEXT, "This is a Test.");
tweetIntent.setType("text/plain");

PackageManager packManager = getPackageManager();
List<ResolveInfo> resolvedInfoList = packManager.queryIntentActivities(tweetIntent,  PackageManager.MATCH_DEFAULT_ONLY);

boolean resolved = false;
for(ResolveInfo resolveInfo: resolvedInfoList){
  if(resolveInfo.activityInfo.packageName.startsWith("com.twitter.android")){
    tweetIntent.setClassName(
      resolveInfo.activityInfo.packageName, 
      resolveInfo.activityInfo.name );
    resolved = true;
    break;
  }
}
if(resolved){
  startActivity(tweetIntent);
}else{
  Toast.makeText(this, "Twitter app isn't found", Toast.LENGTH_LONG).show();
}

代码示例来源:origin: stackoverflow.com

public void shareTwitter() {
   String message = "Your message to post";
   try {
     Intent sharingIntent = new Intent(Intent.ACTION_SEND);
     sharingIntent.setClassName("com.twitter.android","com.twitter.android.PostActivity");
     sharingIntent.putExtra(Intent.EXTRA_TEXT, message);
     startActivity(sharingIntent);
   } catch (Exception e) {
     Log.e("In Exception", "Comes here");
     Intent i = new Intent();
     i.putExtra(Intent.EXTRA_TEXT, message);
     i.setAction(Intent.ACTION_VIEW);
     i.setData(Uri.parse("https://mobile.twitter.com/compose/tweet"));
     startActivity(i);
   }
 }

代码示例来源:origin: stackoverflow.com

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
  switch(item.getItemId())
  {
    case R.id.preferences:
    {
      Intent intent = new Intent();
      intent.setClassName(this, "your.package.MyPreferenceActivity");
      startActivity(intent);
      return true;
    }
  }

  return super.onOptionsItemSelected(item);
}

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.google.android.apps.plus",
"com.google.android.apps.plus.phone.UrlGatewayActivity");
intent.putExtra("customAppUri", "FAN_PAGE_ID");
startActivity(intent);

代码示例来源:origin: stackoverflow.com

private static final String SCHEME = "package";

private static final String APP_PKG_NAME_21 = "com.android.settings.ApplicationPkgName";

private static final String APP_PKG_NAME_22 = "pkg";

private static final String APP_DETAILS_PACKAGE_NAME = "com.android.settings";

private static final String APP_DETAILS_CLASS_NAME = "com.android.settings.InstalledAppDetails";

public static void showInstalledAppDetails(Context context, String packageName) {
  Intent intent = new Intent();
  final int apiLevel = Build.VERSION.SDK_INT;
  if (apiLevel >= 9) { // above 2.3
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts(SCHEME, packageName, null);
    intent.setData(uri);
  } else { // below 2.3
    final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22
        : APP_PKG_NAME_21);
    intent.setAction(Intent.ACTION_VIEW);
    intent.setClassName(APP_DETAILS_PACKAGE_NAME,
        APP_DETAILS_CLASS_NAME);
    intent.putExtra(appPkgName, packageName);
  }
  context.startActivity(intent);
}

代码示例来源:origin: stackoverflow.com

Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.setClassName(this,"com.mainscreen.activity2");
startActivity(intent);

相关文章

Intent类方法