Example usage for android.content Intent setClassName

List of usage examples for android.content Intent setClassName

Introduction

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

Prototype

public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) 

Source Link

Document

Convenience for calling #setComponent with an explicit application package name and class name.

Usage

From source file:Main.java

public static void goToMiuiPermissionActivity_V6(Context context) {
    Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
    intent.setClassName("com.miui.securitycenter",
            "com.miui.permcenter.permissions.AppPermissionsEditorActivity");
    intent.putExtra("extra_pkgname", context.getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (isIntentAvailable(intent, context)) {
        context.startActivity(intent);/*w w  w .jav a 2  s  . c om*/
    } else {
        Log.e(TAG, "Intent is not available!");
    }
}

From source file:org.mozilla.gecko.GuestSession.java

private static PendingIntent getNotificationIntent(Context context) {
    Intent intent = new Intent(NOTIFICATION_INTENT);
    intent.setClassName(context, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
    return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:Main.java

public static void goToMiuiPermissionActivity_V8(Context context) {
    Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
    intent.setClassName("com.miui.securitycenter", "com.miui.permcenter.permissions.PermissionsEditorActivity");
    //        intent.setPackage("com.miui.securitycenter");
    intent.putExtra("extra_pkgname", context.getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (isIntentAvailable(intent, context)) {
        context.startActivity(intent);//from  w w w .j av a 2 s. c  o m
    } else {
        intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
        intent.setPackage("com.miui.securitycenter");
        intent.putExtra("extra_pkgname", context.getPackageName());
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        if (isIntentAvailable(intent, context)) {
            context.startActivity(intent);
        } else {
            Log.e(TAG, "Intent is not available!");
        }
    }
}

From source file:Main.java

public static void startAttention(Context context, String s) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    intent.setData(Uri.parse(s));//w  w  w .  j a v  a2s  . co m
    intent.setClassName("com.tencent.mm", "com.tencent.mm.ui.qrcode.GetQRCodeInfoUI");
    context.startActivity(intent);
}

From source file:com.codyy.lib.utils.ActivityUtils.java

/**
 * ?Activity//from w w w  . j a v a2s .co m
 *
 * @param context     
 * @param packageName ??
 * @param className   activity??
 * @return {@code true}: <br>{@code false}: ?
 */
public static boolean isActivityExists(Context context, String packageName, String className) {
    Intent intent = new Intent();
    intent.setClassName(packageName, className);
    return !(context.getPackageManager().resolveActivity(intent, 0) == null
            || intent.resolveActivity(context.getPackageManager()) == null
            || context.getPackageManager().queryIntentActivities(intent, 0).size() == 0);
}

From source file:Main.java

/**
 * Checks the availability of the DownloadManager.
 *
 * @param context used to update the device version and DownloadManager information
 * @return true if the download manager is available
 *///from  w ww  . j a  v a  2  s. c om
public static boolean isDownloadManagerAvailable(Context context) {
    try {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
            return false;
        }
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setClassName("com.android.providers.downloads.ui",
                "com.android.providers.downloads.ui.DownloadList");
        List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return !list.isEmpty();
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

/**
 * @param context used to check the device version and DownloadManager information
 * @return true if the download manager is available
 *///from w  ww  .  ja  va2s .c o  m
//http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog
public static boolean isDownloadManagerAvailable() {
    try {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
            return false;
        }
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setClassName("com.android.providers.downloads.ui",
                "com.android.providers.downloads.ui.DownloadList");
        List<ResolveInfo> list = m_TempContext.getPackageManager().queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return list.size() > 0;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static void notifyFileSystemChanged(String path, Context mContext) {
    if (path == null)
        return;/*from www  .ja va  2s . com*/
    final File f = new File(path);
    final Intent intent;
    if (f.isDirectory()) {
        intent = new Intent(Intent.ACTION_MEDIA_MOUNTED);
        intent.setClassName("com.android.providers.media", "com.android.providers.media.MediaScannerReceiver");
        intent.setData(Uri.fromFile(Environment.getExternalStorageDirectory()));

    } else {
        intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        intent.setData(Uri.fromFile(new File(path)));

    }
    mContext.sendBroadcast(intent);
}

From source file:Main.java

/**
 * @param context/*from w  ww .java 2 s.c  om*/
 *            used to check the device version and DownloadManager
 *            information
 * @return true if the download manager is available
 */
public static boolean isDownloadManagerAvailable(Context context) {
    try {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
            return false;
        }
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setClassName("com.android.providers.downloads.ui",
                "com.android.providers.downloads.ui.DownloadList");
        List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return list.size() > 0;
    } catch (Exception e) {
        return false;
    }
}

From source file:com.skubit.iab.activities.TransactionDetailsActivity.java

public static Intent newIntent(String data, String packageName) {
    Intent intent = new Intent();
    intent.setClassName(packageName, TransactionDetailsActivity.class.getName());
    intent.putExtra("transaction", data);
    return intent;
}