List of usage examples for android.content Intent setComponent
public @NonNull Intent setComponent(@Nullable ComponentName component)
From source file:com.b44t.messenger.MusicPlayerService.java
@SuppressLint("NewApi") @Override//w w w.j a va2 s . c om public int onStartCommand(Intent intent, int flags, int startId) { try { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { FileLog.e("messenger", e); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:com.claricetechnologies.receivers.ClGcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName component = new ComponentName(context.getPackageName(), ClGcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(component))); setResultCode(Activity.RESULT_OK);// ww w . j av a 2 s . co m }
From source file:com.binarywalllabs.sendit.managers.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(), 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 ava2 s .c o m }
From source file:com.actionbarsherlock.internal.view.menu.ActionMenu.java
public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, android.view.MenuItem[] outSpecificItems) { PackageManager pm = mContext.getPackageManager(); final List<ResolveInfo> lri = pm.queryIntentActivityOptions(caller, specifics, intent, 0); final int N = lri != null ? lri.size() : 0; if ((flags & FLAG_APPEND_TO_GROUP) == 0) { removeGroup(groupId);/*ww w. j a va 2 s .co m*/ } for (int i = 0; i < N; i++) { final ResolveInfo ri = lri.get(i); Intent rintent = new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]); rintent.setComponent( new ComponentName(ri.activityInfo.applicationInfo.packageName, ri.activityInfo.name)); final MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)) .setIntent(rintent); if (outSpecificItems != null && ri.specificIndex >= 0) { outSpecificItems[ri.specificIndex] = item; } } return N; }
From source file:com.meiste.greg.ptw.gcm.GcmBroadcastReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. final 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 w w . ja va2s .c om*/ }
From source file:com.survey.android.c2dm.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmNotificationReceiver will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GcmNotificationReceiver.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 a2 s. co m }
From source file:org.authme.android.gcm.GCMReceiver.java
@Override public void onReceive(Context context, Intent intent) { // 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 w w .ja v a 2s . c o m*/ }
From source file:com.letsgood.sampleapp.receivers.GoogleCloudMessageReceiver.java
@Override public void onReceive(Context context, Intent intent) { // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), NotificationIntent.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 .j a va2 s .c om*/ }
From source file:com.ferdi2005.secondgram.MusicPlayerService.java
@SuppressLint("NewApi") @Override/*w w w. ja v a 2s . c om*/ public int onStartCommand(Intent intent, int flags, int startId) { try { MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject(); if (messageObject == null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { stopSelf(); } }); return START_STICKY; } if (supportLockScreenControls) { ComponentName remoteComponentName = new ComponentName(getApplicationContext(), MusicPlayerReceiver.class.getName()); try { if (remoteControlClient == null) { audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE | RemoteControlClient.FLAG_KEY_MEDIA_STOP | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS | RemoteControlClient.FLAG_KEY_MEDIA_NEXT); } catch (Exception e) { FileLog.e(e); } } createNotification(messageObject); } catch (Exception e) { e.printStackTrace(); } return START_STICKY; }
From source file:com.nks.nksmod.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from w w w .j a v a 2s . c o m*/ public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_info) { Intent intent = new Intent(this, InformationActivity.class); startActivity(intent); } if (id == R.id.nav_update) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(ComponentName .unflattenFromString("com.nks.nksmod.otaupdater/com.nks.nksmod.otaupdater.OTAUpdaterActivity")); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } /* if (id == R.id.nav_gallery) { } else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_manage) { } else if (id == R.id.nav_share) { } else if (id == R.id.nav_send) { } */ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }