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

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

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

Intent.setAction介绍

暂无

代码示例

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

private void openScreenshot(File imageFile) {
  Intent intent = new Intent();
  intent.setAction(Intent.ACTION_VIEW);
  Uri uri = Uri.fromFile(imageFile);
  intent.setDataAndType(uri, "image/*");
  startActivity(intent);
}

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

/** on your logout method:**/
Intent broadcastIntent = new Intent();
broadcastIntent.setAction("com.package.ACTION_LOGOUT");
sendBroadcast(broadcastIntent);

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

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);

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

Intent intent = new Intent();  
intent.setAction(android.content.Intent.ACTION_VIEW);  
File file = new File(YOUR_SONG_URI);  
intent.setDataAndType(Uri.fromFile(file), "audio/*");  
startActivity(intent);

代码示例来源:origin: smuyyh/BookReader

public static void start(Context context, String filePath) {
  Intent intent = new Intent(context, ReadCHMActivity.class);
  intent.setAction(Intent.ACTION_VIEW);
  intent.setData(Uri.fromFile(new File(filePath)));
  context.startActivity(intent);
}

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

Intent intent = new Intent(this,MyAppWidgetProvider.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
// Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID,
// since it seems the onUpdate() is only fired on that:
int[] ids = {widgetId};
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,ids);
sendBroadcast(intent);

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

public void onBackPressed() {    
  Intent intent = new Intent();
  intent.setAction(Intent.ACTION_MAIN);
  intent.addCategory(Intent.CATEGORY_HOME);
  startActivity(intent);
}

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

final Intent notificationIntent = new Intent(context, YourActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

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

Intent intent = new Intent();
 intent.setType("image/*");
 intent.setAction(Intent.ACTION_GET_CONTENT);
 intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
 startActivityForResult(Intent.createChooser(intent,
     "Complete action using"), PHOTO_PICKER_ID);

代码示例来源:origin: smuyyh/BookReader

public static void start(Context context, String filePath) {
  Intent intent = new Intent(context, ReadEPubActivity.class);
  intent.setAction(Intent.ACTION_VIEW);
  intent.setData(Uri.fromFile(new File(filePath)));
  context.startActivity(intent);
}

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

public static void startActionUpvote(@NonNull Context context, long storyId) {
  final Intent intent = new Intent(context, UpvoteStoryService.class);
  intent.setAction(ACTION_UPVOTE);
  intent.putExtra(EXTRA_STORY_ID, storyId);
  context.startService(intent);
}

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

ImageView img = (ImageView)findViewById(R.id.foo_bar);
img.setOnClickListener(new View.OnClickListener(){
  public void onClick(View v){
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    intent.setData(Uri.parse("http://casidiablo.net"));
    startActivity(intent);
  }
});

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

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");
startActivity(intent);

代码示例来源:origin: google/ExoPlayer

private static Intent getIntent(
  Context context, Class<? extends DownloadService> clazz, String action) {
 return new Intent(context, clazz).setAction(action);
}

代码示例来源:origin: crazycodeboy/TakePhoto

/**
 * 获取选择照片的Intent
 *
 * @return
 */
public static Intent getPickIntentWithGallery() {
  Intent intent = new Intent();
  intent.setAction(Intent.ACTION_PICK);//Pick an item from the data
  intent.setType("image/*");//从所有图片中进行选择
  return intent;
}

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

Intent intent = new Intent(context, SplashScreen.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // You need this if starting
                        //  the activity from a service
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(intent);

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

File imagePath = new File(context.getCacheDir(), "images");
File newFile = new File(imagePath, "image.png");
Uri contentUri = FileProvider.getUriForFile(context, "com.example.myapp.fileprovider", newFile);

if (contentUri != null) {
  Intent shareIntent = new Intent();
  shareIntent.setAction(Intent.ACTION_SEND);
  shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // temp permission for receiving app to read this file
  shareIntent.setDataAndType(contentUri, getContentResolver().getType(contentUri));
  shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
  startActivity(Intent.createChooser(shareIntent, "Choose an app"));
}

代码示例来源:origin: smuyyh/BookReader

public static void start(Context context, String filePath) {
  Intent intent = new Intent(context, ReadPDFActivity.class);
  intent.setAction(Intent.ACTION_VIEW);
  intent.setData(Uri.fromFile(new File(filePath)));
  context.startActivity(intent);
}

代码示例来源:origin: naman14/Timber

public static Intent getNavigateToStyleSelectorIntent(Activity context, String what) {
  final Intent intent = new Intent(context, SettingsActivity.class);
  intent.setAction(Constants.SETTINGS_STYLE_SELECTOR);
  intent.putExtra(Constants.SETTINGS_STYLE_SELECTOR_WHAT, what);
  return intent;
}

代码示例来源:origin: JessYanCoding/MVPArms

public static boolean isHaveMarket(Context context) {
  Intent intent = new Intent();
  intent.setAction("android.intent.action.MAIN");
  intent.addCategory("android.intent.category.APP_MARKET");
  PackageManager pm = context.getPackageManager();
  List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0);
  return infos.size() > 0;
}

相关文章

Intent类方法