Example usage for android.content Intent setComponent

List of usage examples for android.content Intent setComponent

Introduction

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

Prototype

public @NonNull Intent setComponent(@Nullable ComponentName component) 

Source Link

Document

(Usually optional) Explicitly set the component to handle the intent.

Usage

From source file:com.liferay.alerts.receiver.PushNotificationReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    ComponentName component = new ComponentName(context.getPackageName(),
            PushNotificationService.class.getName());

    intent.setComponent(component);

    startWakefulService(context, intent);
    setResultCode(Activity.RESULT_OK);//w ww  . j a v  a  2 s. c  om
}

From source file:org.wso2.emm.agent.GCMBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    ComponentName componentName = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());
    startWakefulService(context, (intent.setComponent(componentName)));
    setResultCode(Activity.RESULT_OK);//from  ww  w  .jav  a2  s  .  com
}

From source file:Main.java

private static void shareImageOnFacebook(String imagePath, Context context) {

    Log.d("CitationsManager-ShareOnFb", "sharing the image " + imagePath);
    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    // shareIntent.putExtra(Intent.EXTRA_TEXT, "www.google.com");
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
    for (final ResolveInfo app : activityList) {

        Log.d("CitationsManager-ShareOnFb", app.activityInfo.name);
        if ((app.activityInfo.name).contains("com.facebook") && !(app.activityInfo.name).contains("messenger")
                && !(app.activityInfo.name).contains("pages")) {
            final ActivityInfo activity = app.activityInfo;
            final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
            shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
            shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            shareIntent.setComponent(name);
            context.startActivity(shareIntent);
            break;
        }/*  w  ww.jav a 2  s.com*/
    }

}

From source file:de.Maxr1998.maxlock.thememanager.navigation.drawer.NavigationDrawerFragment.java

@Override
public void onClick(View view) {
    switch (view.getId()) {
    case R.id.store:
        startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("http://play.google.com/store/search?q=pub:Maxr1998")));
        break;//w  w  w  .ja v a  2s .  co m
    case R.id.return_maxlock:
        Intent maxlock = new Intent();
        maxlock.setComponent(new ComponentName("de.Maxr1998.xposed.maxlock",
                "de.Maxr1998.xposed.maxlock" + ".ui.SettingsActivity"));
        maxlock.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(maxlock);
        break;
    }
}

From source file:org.chromium.chrome.browser.sync.SyncNotificationController.java

/**
 * Creates an intent that launches an activity that requests the users password/passphrase.
 *
 * @return the intent for opening the password/passphrase activity
 *///from   w ww  . j a v a2s  .  co  m
private Intent createPasswordIntent() {
    // Make sure we don't prompt too many times.
    mProfileSyncService.setPassphrasePrompted(true);

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setComponent(new ComponentName(mApplicationContext, mPassphraseRequestActivity));
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    // This activity will become the start of a new task on this history stack.
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    // Clears the task stack above this activity if it already exists.
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    return intent;
}

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

public void handleDirectMessage(Context context, Contact from, JSONObject obj) {
    Intent launch = new Intent();
    launch.setAction(Intent.ACTION_MAIN);
    launch.addCategory(Intent.CATEGORY_LAUNCHER);
    launch.setComponent(new ComponentName(context.getPackageName(), HomeActivity.class.getName()));
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch,
            PendingIntent.FLAG_CANCEL_CURRENT);
    String msg = obj.optString(TEXT);
    (new PresenceAwareNotify(context)).notify("IM from " + from.name, "IM from " + from.name, "\"" + msg + "\"",
            contentIntent);//from   w w  w .  ja  va2s .c  o m
}

From source file:com.ashish.msngr.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    ComponentName comp = new ComponentName(context.getPackageName(),
            GCMNotificationIntentService.class.getName());
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);//  www  . j  a va2  s  .c o m
}

From source file:org.sufficientlysecure.localcalendar.ui.ActivityNotFoundDialogFragment.java

/**
 * Creates dialog//  w  w  w  .j av a 2 s .c  o m
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();

    final String appGooglePlayUri = getArguments().getString(ARG_APP_GOOGLE_PLAY_URI);
    final String appFDroidQuery = getArguments().getString(ARG_APP_FDROID_QUERY);
    final int title = getArguments().getInt(ARG_TITLE);
    final int message = getArguments().getInt(ARG_MESSAGE);

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Intent intentGooglePlay = new Intent(Intent.ACTION_VIEW);
            intentGooglePlay.setData(Uri.parse(appGooglePlayUri));

            try {
                activity.startActivity(intentGooglePlay);
            } catch (ActivityNotFoundException e) {
                Log.e(TAG, "No Google Play Store installed!, Trying FDroid...", e);

                Intent intentFDroid = new Intent(Intent.ACTION_SEARCH);
                intentFDroid.setComponent(
                        new ComponentName("org.fdroid.fdroid", "org.fdroid.fdroid.SearchResults"));
                intentFDroid.putExtra(SearchManager.QUERY, appFDroidQuery);

                try {
                    activity.startActivity(intentFDroid);
                } catch (ActivityNotFoundException e2) {
                    Log.e(TAG, "No FDroid installed!", e2);
                }
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });

    builder.setTitle(title);
    builder.setMessage(message);

    return builder.create();
}

From source file:org.adaway.ui.dialog.ActivityNotFoundDialogFragment.java

/**
 * Creates dialog//  w  w w.j a v a  2 s.  co m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();

    final String appGooglePlayUri = getArguments().getString(ARG_APP_GOOGLE_PLAY_URI);
    final String appFDroidQuery = getArguments().getString(ARG_APP_FDROID_QUERY);
    final int title = getArguments().getInt(ARG_TITLE);
    final int message = getArguments().getInt(ARG_MESSAGE);

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Intent intentGooglePlay = new Intent(Intent.ACTION_VIEW);
            intentGooglePlay.setData(Uri.parse(appGooglePlayUri));

            try {
                activity.startActivity(intentGooglePlay);
            } catch (ActivityNotFoundException e) {
                Log.e(Constants.TAG, "No Google Play Store installed!, Trying FDroid...", e);

                Intent intentFDroid = new Intent(Intent.ACTION_SEARCH);
                intentFDroid.setComponent(
                        new ComponentName("org.fdroid.fdroid", "org.fdroid.fdroid.SearchResults"));
                intentFDroid.putExtra(SearchManager.QUERY, appFDroidQuery);

                try {
                    activity.startActivity(intentFDroid);
                } catch (ActivityNotFoundException e2) {
                    Log.e(Constants.TAG, "No FDroid installed!", e2);
                }
            }
        }
    });
    builder.setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });

    builder.setTitle(title);
    builder.setMessage(message);

    return builder.create();
}

From source file:it.gcaliendo.elytheme.fragments.FragmentExtras.java

private void actRequest() {
    String pkg = getResources().getString(R.string.pkg);
    Intent iconrequest = new Intent(Intent.ACTION_MAIN);
    iconrequest.setComponent(new ComponentName(pkg, pkg + ".RequestActivity"));

    try {/*  www  .  ja  va2 s . c om*/
        startActivity(iconrequest);
    } catch (RuntimeException icons) {
        icons.printStackTrace();
    }
}