Example usage for android.content Intent setAction

List of usage examples for android.content Intent setAction

Introduction

In this page you can find the example usage for android.content Intent setAction.

Prototype

public @NonNull Intent setAction(@Nullable String action) 

Source Link

Document

Set the general action to be performed.

Usage

From source file:Main.java

public static void uninstallApp(String packageName, Activity activity) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.DELETE");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.setData(Uri.parse("package:" + packageName));
    activity.startActivityForResult(intent, 0);
}

From source file:Main.java

public static void pickImageFromAlbum2(final Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_PICK);
    intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    activity.startActivityForResult(intent, REQUEST_CODE_FROM_ALBUM);
}

From source file:Main.java

private static void uninstallAppByClick(Context context, String pkgName) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DELETE);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse("package:" + pkgName));
    context.startActivity(intent);/*from   w  w  w .  j  a  v a2s. co m*/
}

From source file:Main.java

public static void installAPK(Context context, File apkFile) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    context.startActivity(intent);/*  w ww . j a  v a2 s.  com*/
}

From source file:Main.java

public static void pauseMusic(Context context) {
    Intent freshIntent = new Intent();
    freshIntent.setAction("com.android.music.musicservicecommand.pause");
    freshIntent.putExtra("command", "pause");
    context.sendBroadcast(freshIntent);//from w w w . j  a  v  a  2  s .com
}

From source file:Main.java

public static void FindPhoto(Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");

    activity.startActivityForResult(intent, REQUEST_CODE_FROM_ALBUM);
}

From source file:Main.java

public static void shareText(Activity activity, String title, String text) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, text);
    sendIntent.setType("text/plain");
    activity.startActivity(Intent.createChooser(sendIntent, title));
}

From source file:Main.java

public static void downloadApkFromBrower(Context context, String url) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri content_url = Uri.parse(url);/*from  ww  w . ja  v a  2  s  . c o  m*/
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(content_url);
    context.startActivity(intent);
}

From source file:Main.java

public static boolean settings(Context context, PackageInfo packageInfo) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.parse("package:" + packageInfo.packageName));
    context.startActivity(intent);/*from   w w  w . j a v  a2 s . c  o m*/
    return true;
}

From source file:Main.java

public static void openApplicationSettings(Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
    intent.setData(uri);/*from  w ww .  j  a va 2s. c  om*/
    activity.startActivity(intent);
}