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:com.skubit.iab.activities.SkubitAndroidActivity.java

public static Intent newInstance(Context context) {
    Intent i = new Intent();
    i.setClassName(Flavor.VALUE, SkubitAndroidActivity.class.getName());
    return i;//from   www  .  j a  va  2s. co m
}

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

/**
 * Launch a notification of the data policy, and record notification time and version.
 *//*from w  w  w  .  j  a  v  a  2s.co  m*/
private static void notifyDataPolicy(Context context, SharedPreferences sharedPrefs) {
    boolean result = false;
    try {
        // Launch main App to launch Data choices when notification is clicked.
        Intent prefIntent = new Intent(GeckoApp.ACTION_LAUNCH_SETTINGS);
        prefIntent.setClassName(AppConstants.ANDROID_PACKAGE_NAME,
                AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);

        GeckoPreferences.setResourceToOpen(prefIntent, "preferences_vendor");
        prefIntent.putExtra(ALERT_NAME_DATAREPORTING_NOTIFICATION, true);

        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, prefIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        final Resources resources = context.getResources();

        // Create and send notification.
        String notificationTitle = resources.getString(R.string.datareporting_notification_title);
        String notificationSummary;
        if (Versions.preJB) {
            notificationSummary = resources.getString(R.string.datareporting_notification_action);
        } else {
            // Display partial version of Big Style notification for supporting devices.
            notificationSummary = resources.getString(R.string.datareporting_notification_summary);
        }
        String notificationAction = resources.getString(R.string.datareporting_notification_action);
        String notificationBigSummary = resources.getString(R.string.datareporting_notification_summary);

        // Make styled ticker text for display in notification bar.
        String tickerString = resources.getString(R.string.datareporting_notification_ticker_text);
        SpannableString tickerText = new SpannableString(tickerString);
        // Bold the notification title of the ticker text, which is the same string as notificationTitle.
        tickerText.setSpan(new StyleSpan(Typeface.BOLD), 0, notificationTitle.length(),
                Spannable.SPAN_INCLUSIVE_EXCLUSIVE);

        Notification notification = new NotificationCompat.Builder(context).setContentTitle(notificationTitle)
                .setContentText(notificationSummary).setSmallIcon(R.drawable.ic_status_logo).setAutoCancel(true)
                .setContentIntent(contentIntent)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(notificationBigSummary))
                .addAction(R.drawable.firefox_settings_alert, notificationAction, contentIntent)
                .setTicker(tickerText).build();

        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        int notificationID = ALERT_NAME_DATAREPORTING_NOTIFICATION.hashCode();
        notificationManager.notify(notificationID, notification);

        // Record version and notification time.
        SharedPreferences.Editor editor = sharedPrefs.edit();
        long now = System.currentTimeMillis();
        editor.putLong(PREFS_POLICY_NOTIFIED_TIME, now);
        editor.putInt(PREFS_POLICY_VERSION, DATA_REPORTING_VERSION);
        editor.apply();
        result = true;
    } finally {
        // We want to track any errors, so record notification outcome.
        Telemetry.sendUIEvent(TelemetryContract.Event.POLICY_NOTIFICATION_SUCCESS, result);
    }
}

From source file:Main.java

/** -----------------------------------------------------------------------  Google Maps -- */

public static Intent newOpenMapsAtLatLongAndName(String latitude, String longitude, String name) {
    Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse(String.format(Locale.ENGLISH, "geo:%s,%s", latitude, longitude) + "?q="
                    + Uri.encode(latitude + "," + longitude + "(" + name + ")") + "&z=16"));
    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    return intent;
}

From source file:es.gaedr_space.puntogpsqr.QRVisorFragment.java

/**
 * Mtodo que genera el Intent de la aplicacin de Google Maps que seala la ruta entre dos puntos
 *
 * @param myLocation Localizacin de partida
 * @param destiny    Localizacin destino
 * @return Intent correspondiente a la aplicacin con los parmetros
 *///from w  w w  .j  av a2s  . co m
public static Intent mapsLauncher(SiteLocation myLocation, SiteLocation destiny) {
    String url = "http://maps.google.com/maps?saddr=" + myLocation.getLatitude() + ","
            + myLocation.getLongitude() + "&daddr=" + destiny.getLatitude() + "," + destiny.getLongitude();
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
    return intent;
}

From source file:org.mozilla.gecko.tabqueue.TabQueueHelper.java

/**
 * Displays a notification showing the total number of tabs queue.  If there is already a notification displayed, it
 * will be replaced./*from w w w  . j  av  a  2s .c  o  m*/
 *
 * @param context
 * @param tabsQueued
 */
public static void showNotification(final Context context, final int tabsQueued) {
    ThreadUtils.assertNotOnUiThread();

    Intent resultIntent = new Intent();
    resultIntent.setClassName(context, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
    resultIntent.setAction(TabQueueHelper.LOAD_URLS_ACTION);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    final String text;
    final Resources resources = context.getResources();
    if (tabsQueued == 1) {
        text = resources.getString(R.string.tab_queue_notification_text_singular);
    } else {
        text = resources.getString(R.string.tab_queue_notification_text_plural, tabsQueued);
    }

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_status_logo)
            .setContentTitle(resources.getString(R.string.tab_queue_notification_title)).setContentText(text)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(TabQueueHelper.TAB_QUEUE_NOTIFICATION_ID, builder.build());
}

From source file:at.wada811.utils.IntentUtils.java

/**
 * Gmail?Intent??//from   w  w w . j  av a 2 s.  c o m
 *
 * @param intent
 * @return
 */
public static Intent createGmailIntent(Intent baseIntent) {
    Intent intent = new Intent(baseIntent);
    intent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
    return intent;
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppObj.java

public static Intent getLaunchIntent(Context context, DbObj obj) {
    JSONObject content = obj.getJson();/*  w ww .  j a  v a2  s. c  om*/
    if (content.has(ANDROID_PACKAGE_NAME)) {
        Uri appFeed = obj.getContainingFeed().getUri();
        String action = content.optString(ANDROID_ACTION);
        String pkgName = content.optString(ANDROID_PACKAGE_NAME);
        String className = content.optString(ANDROID_CLASS_NAME);

        Intent launch = new Intent(action);
        launch.setClassName(pkgName, className);
        launch.addCategory(Intent.CATEGORY_LAUNCHER);
        // TODO: feed for related objs, not parent feed
        launch.putExtra(AppState.EXTRA_FEED_URI, appFeed);
        launch.putExtra(AppState.EXTRA_OBJ_HASH, obj.getHash());
        // TODO: Remove
        launch.putExtra("obj", content.toString());

        List<ResolveInfo> resolved = context.getPackageManager().queryIntentActivities(launch, 0);
        if (resolved.size() > 0) {
            return launch;
        }

        Intent market = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + pkgName));
        return market;
    } else if (content.has(WEB_URL)) {
        Intent app = new Intent(Intent.ACTION_VIEW, Uri.parse(content.optString(WEB_URL)));
        app.setClass(context, AppFinderActivity.class);
        app.putExtra(Musubi.EXTRA_FEED_URI, Feed.uriForName(obj.getFeedName()));
        return app;
    }
    return null;
}

From source file:Main.java

@SuppressLint("InlinedApi")
public static void openSys(Context context, String packageName) {
    Intent intent = new Intent();
    final int apiLevel = Build.VERSION.SDK_INT;
    if (apiLevel >= 9) {
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.setData(Uri.fromParts("package", packageName, null));
    } else {/*from   w  w w.j ava  2s .c o  m*/
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
        String appPkgName = (apiLevel == 8 ? "pkg" : "com.android.settings.ApplicationPkgName");
        intent.putExtra(appPkgName, packageName);
    }
    context.startActivity(intent);
}

From source file:Main.java

public static void goToInstalledAppDetails(Context context, String packageName) {
    Intent intent = new Intent();
    int sdkVersion = Build.VERSION.SDK_INT;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.setData(Uri.fromParts("package", packageName, null));
    } else {//from  w w  w  .j  av a  2s .  c  o m
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
        intent.putExtra(
                (sdkVersion == Build.VERSION_CODES.FROYO ? "pkg" : "com.android.settings.ApplicationPkgName"),
                packageName);
    }
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

From source file:com.mediatek.contacts.activities.ActivitiesUtils.java

public static boolean conferenceCall(Activity activity) {
    Log.i(TAG, "[conferenceCall]...");
    final Intent intent = new Intent();
    intent.setClassName(activity, "com.mediatek.contacts.list.ContactListMultiChoiceActivity").setAction(
            com.mediatek.contacts.util.ContactsIntent.LIST.ACTION_PICK_MULTI_PHONEANDIMSANDSIPCONTACTS);
    intent.putExtra(com.mediatek.contacts.util.ContactsIntent.CONFERENCE_SENDER,
            com.mediatek.contacts.util.ContactsIntent.CONFERENCE_CONTACTS);
    activity.startActivity(intent);//from   ww w .  j  a v a  2 s .  c  o m

    return true;
}