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:org.catrobat.catroid.ui.dialogs.NewLookDialog.java

private void setupPaintroidButton(View parentView) {
    View paintroidButton = parentView.findViewById(R.id.dialog_new_look_paintroid);

    final Intent intent = new Intent("android.intent.action.MAIN");
    intent.setComponent(new ComponentName(Constants.POCKET_PAINT_PACKAGE_NAME,
            Constants.POCKET_PAINT_INTENT_ACTIVITY_NAME));

    paintroidButton.setOnClickListener(new View.OnClickListener() {
        @Override/*w ww .j av  a 2 s.c o  m*/
        public void onClick(View view) {
            if (LookController.getInstance().checkIfPocketPaintIsInstalled(intent, getActivity())) {
                fragment.addLookDrawNewImage();
                NewLookDialog.this.dismiss();
            }
        }
    });
}

From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.internal.MFPPushBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    ComponentName component = new ComponentName(context.getPackageName(), MFPPushIntentService.class.getName());
    startWakefulService(context, (intent.setComponent(component)));
    setResultCode(Activity.RESULT_OK);/*ww  w.  j  a v  a 2  s .c  om*/
}

From source file:org.ado.minesync.gui.notification.MineSyncNotification.java

private PendingIntent getSyncAction(String action) {
    final ComponentName serviceName = new ComponentName(service, MineSyncService.class);
    Intent intent = new Intent(action);
    intent.setComponent(serviceName);
    return PendingIntent.getService(service, getRequestCode(action), intent, 0);
}

From source file:com.cordova.plugins.startapp.StartApp.java

/**
 * Starts an activity./*from w w w.  j  a va 2 s. c o m*/
 *
 * @param component
 *            Activity ComponentName.
 *            E.g.: com.mycompany.myapp/com.mycompany.myapp.MyActivity
 */
void startActivity(String component) {
    try {
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.LAUNCHER");
        intent.setComponent(ComponentName.unflattenFromString(component));
        ((DroidGap) this.cordova.getActivity()).startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        /**
         * If not installed, open market
         */
        String[] packageNameSplt = component.split("/");
        String packageName = packageNameSplt[0];

        Intent marketIntent = new Intent(Intent.ACTION_VIEW);
        marketIntent.setData(Uri.parse("market://details?id=" + packageName));
        ((DroidGap) this.cordova.getActivity()).startActivity(marketIntent);
    }
}

From source file:eu.nerdz.app.messenger.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    ComponentName component = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());

    WakefulBroadcastReceiver.startWakefulService(context, intent.setComponent(component));

    this.setResultCode(Activity.RESULT_OK);

}

From source file:com.mozilla.simplepush.simplepushdemoapp.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.i("SimplePushDemo", "onReceive...");
    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*from w  ww .  ja va  2 s .c om*/
}

From source file:com.diusrex.toforeground.ToForeground.java

public boolean execute(String className, JSONArray args, CallbackContext callbackContext) throws JSONException {
    try {/*from  w w  w. jav  a2  s  .c  o m*/
        Intent it = new Intent("android.intent.action.MAIN");

        String packageName = args.getString(0);

        Activity activity = this.cordova.getActivity();
        it.setComponent(new ComponentName(packageName, packageName + "." + className));
        it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        Context context = activity.getApplicationContext();
        context.startActivity(it);
    } catch (Exception e) {
        return false;
    }
    return true;
}

From source file:com.kakao.game.sample.push.GcmBroadcastReceiver.java

/**
 *  ? ?,   ?  sleep ?? wake lock?  {@link com.kakao.game.sample.push.GcmIntentService}  .
 * @param context ? /*from   w  w  w  .j  a va 2 s  .  c o  m*/
 * @param intent     intent
 */
@Override
public void onReceive(Context context, Intent intent) {
    Logger.e("onReceive()");
    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);
}

From source file:com.magnet.mmx.client.MMXGcmBroadcastReceiver.java

public void onReceive(Context context, Intent intent) {
    ComponentName component = new ComponentName(context.getPackageName(),
            MMXWakeupIntentService.class.getName());
    startWakefulService(context, (intent.setComponent(component)));
    setResultCode(Activity.RESULT_OK);//from w  ww. ja v a 2  s .  c o  m
}

From source file:com.umeng.comm.ui.fragments.RecommendTopicFragment.java

@Override
protected void setAdapterGotoDetail() {
    ((RecommendTopicAdapter) mAdapter).setTtt(new TopicToTopicDetail() {
        @Override//from w w  w  . ja va2s. c  o  m
        public void gotoTopicDetail(Topic topic) {
            Intent intent = new Intent();
            ComponentName componentName = new ComponentName(getActivity(), TopicDetailActivity.class);
            intent.setComponent(componentName);
            intent.putExtra(Constants.TAG_TOPIC, topic);
            getActivity().startActivity(intent);
        }
    });
}