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.safetyapp.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.i("SA", "BROADCAST RECEIVER ACTIVATED");
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/* ww w.  j av  a  2s . c o m*/
}

From source file:com.appdynamics.demo.gasp.gcm.GCMBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d(TAG, "Received GCM Message");

    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());

    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));

    setResultCode(Activity.RESULT_OK);//  w  ww .j a va 2  s . c o  m
}

From source file:com.dbztech.universalpresenterremote.upr.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(),
            com.dbztech.universalpresenterremote.upr.GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*from  w  w w  . java  2s .  c  o m*/
}

From source file:com.csform.android.uiapptemplate.gcm.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(),
            com.csform.android.uiapptemplate.gcm.GcmIntentService.class.getName());

    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*w  w w  .  jav  a  2  s  . com*/

}

From source file:com.winginno.charitynow.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.i(TAG, "GcmBroadcastReceiver.onReceive");
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);//w  w  w  . j a  va 2 s  . co  m
}

From source file:edu.dartmouth.cs.myruns.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    // Explicitly specify that GcmIntentService will handle the intent.

    Log.d("", "Received message from server");

    ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);//  w  w  w . j  a v  a  2s  .  com
}

From source file:com.hackathon.BeatTheQueue.reusable.gcm.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.e("GcmBroadcastReceiver", intent.getAction());
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/*from   w  ww .j a v  a 2 s. c  o  m*/
}

From source file:edu.sjsu.jobfair.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.i("A.GcmBroadcastReceiver", "In onReceive()");
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);/* w ww  .  j  a  va 2  s .  c  o  m*/
}

From source file:com.google.android.apps.mytracks.TabManager.java

@Override
public void onTabChanged(String tabId) {
    // Alert if nogago Maps isnt installed
    AlertDialog.Builder notInstalled = new AlertDialog.Builder(fragmentActivity);
    notInstalled.setMessage(R.string.maps_not_installed).setCancelable(false)
            .setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    Uri uri = Uri.parse(Constants.MAPS_DOWNLOAD_URL);
                    Intent showUri = new Intent(Intent.ACTION_VIEW, uri);
                    fragmentActivity.startActivity(showUri);
                }//from   w ww  .j  av  a  2s . c om
            }).setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    final AlertDialog alertnotInstalled = notInstalled.create();

    // Alert if nogago Maps is installed
    AlertDialog.Builder builder = new AlertDialog.Builder(fragmentActivity);
    builder.setMessage(R.string.wanna_start_maps).setCancelable(false)
            .setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    try {
                        if (isRecording()) {
                            String nogagoPackage = "com.nogago.android.maps";
                            String mapActivity = ".activities.MapActivity";
                            Intent intent = new Intent();
                            intent.setComponent(new ComponentName(nogagoPackage, nogagoPackage + mapActivity));
                            fragmentActivity.startActivity(intent);
                        } else {
                            String trackPackage = "com.nogago.android.tracks";
                            String trackDetailActivity = ".TrackDetailActivity";
                            Intent tda = new Intent();
                            tda.setComponent(
                                    new ComponentName(trackPackage, trackPackage + trackDetailActivity));
                            tda.putExtra("clicked", true);

                            fragmentActivity.startActivity(tda);
                        }
                    } catch (NullPointerException e) {
                        alertnotInstalled.show();
                    }
                }
            }).setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();

    if (tabId.compareTo("mapFragment") == 0) {
        try {
            tabId = StatsFragment.STATS_FRAGMENT_TAG;
            // nogagoMaps aufrufen
            this.tabHost.setCurrentTab(1);
            try {
                if (isRecording()) {
                    String nogagoPackage = "com.nogago.android.maps";
                    String mapActivity = ".activities.MapActivity";
                    Intent intent = new Intent();
                    intent.setComponent(new ComponentName(nogagoPackage, nogagoPackage + mapActivity));
                    fragmentActivity.startActivity(intent);
                } else {
                    String trackPackage = "com.nogago.android.tracks";
                    String trackDetailActivity = ".TrackDetailActivity";
                    Intent tda = new Intent();
                    tda.setComponent(new ComponentName(trackPackage, trackPackage + trackDetailActivity));
                    tda.putExtra("clicked", true);

                    fragmentActivity.startActivity(tda);
                }
            } catch (NullPointerException e) {
                alertnotInstalled.show();
            }
            //        alert.show();
            // falls nicht installiert, fragen, ob installiert werden soll
        } catch (NullPointerException e) {

            alertnotInstalled.show();

        }
    }

    TabInfo newTabInfo = tabs.get(tabId);
    if (lastTabInfo != newTabInfo) {
        FragmentTransaction fragmentTransaction = fragmentActivity.getSupportFragmentManager()
                .beginTransaction();
        if (lastTabInfo != null) {
            if (lastTabInfo.fragment != null) {
                fragmentTransaction.detach(lastTabInfo.fragment);
            }
        }
        if (newTabInfo != null) {
            if (newTabInfo.fragment == null) {
                newTabInfo.fragment = Fragment.instantiate(fragmentActivity, newTabInfo.clss.getName(),
                        newTabInfo.bundle);
                fragmentTransaction.add(containerId, newTabInfo.fragment, newTabInfo.tag);
            } else {
                fragmentTransaction.attach(newTabInfo.fragment);
            }
        }

        lastTabInfo = newTabInfo;
        fragmentTransaction.commit();
        fragmentActivity.getSupportFragmentManager().executePendingTransactions();
    }
}

From source file:com.yekertech.tvbarsetting.MainFragment.java

private void loadMenuItem() {
    int i = 0;/*from   w w w.jav  a2  s.  c om*/
    mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());
    ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new MenuItemPresenter());

    Intent intentDisp = new Intent(Intent.ACTION_MAIN);
    intentDisp.setClass(this.getActivity(), DisplayActivity.class);

    Intent intentBt = new Intent(Intent.ACTION_MAIN);
    intentBt.setComponent(new ComponentName("com.android.settings", "com.android.settings.SubSettings"));
    intentBt.putExtra(":settings:show_fragment", "com.android.settings.bluetooth.BluetoothSettings");
    intentBt.putExtra(":settings:show_fragment_title", "Bluetooth");

    Intent intentNetwork = new Intent(Intent.ACTION_MAIN);
    intentNetwork.setClass(this.getActivity(), NetworkActivity.class);

    Intent intentSound = new Intent(Intent.ACTION_MAIN);
    intentSound.setClass(this.getActivity(), SoundActivity.class);

    Intent intentCommon = new Intent(Intent.ACTION_MAIN);
    intentCommon.setClass(this.getActivity(), AboutActivity.class);

    Intent intentAbout = new Intent(Intent.ACTION_MAIN);
    intentAbout.setClass(this.getActivity(), AboutActivity.class);

    listRowAdapter.add(new MenuItem.Builder().id(i++).title("?").backgroundColor(0xff2daae6)
            .imageResourceId(this.getActivity(), R.drawable.ic_settings_display).intent(intentDisp).build());

    listRowAdapter.add(new MenuItem.Builder().id(i++).title("").backgroundColor(0xffe6b41e)
            .imageResourceId(this.getActivity(), R.drawable.ic_settings_sound_on).intent(intentSound).build());

    listRowAdapter.add(new MenuItem.Builder().id(i++).title("?").backgroundColor(0xff329696)
            .imageResourceId(this.getActivity(), R.drawable.ic_settings_bluetooth).intent(intentBt).build());

    listRowAdapter.add(new MenuItem.Builder().id(i++).title("").backgroundColor(0xfff08c23)
            .imageResourceId(this.getActivity(), R.drawable.ic_settings_ethernet).intent(intentNetwork)
            .build());

    listRowAdapter.add(new MenuItem.Builder().id(i++).title("").backgroundColor(0xff737ddc)
            .imageResourceId(this.getActivity(), R.drawable.ic_settings_app_icon).intent(intentCommon).build());

    listRowAdapter.add(new MenuItem.Builder().id(i++).title("").backgroundColor(0xfff55a46)
            .imageResourceId(this.getActivity(), R.drawable.ic_settings_about).intent(intentAbout).build());

    HeaderItem header = new HeaderItem(0, "");
    mRowsAdapter.add(new ListRow(listRowAdapter));
    setAdapter(mRowsAdapter);
}