Refine search
Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new ComponentName("com.package.address","com.package.address.MainActivity")); startActivity(intent);
Intent intent = new Intent(); intent.setComponent(new ComponentName("com.example", "com.example.MyExampleActivity")); startActivity(intent);
Intent i = new Intent(); if(Build.VERSION.SDK_INT > 15){ i.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER); String p = HypercaneWallpaperService.class.getPackage().getName(); String c = HypercaneWallpaperService.class.getCanonicalName(); i.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(p, c)); } else{ i.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); } getActivity().startActivityForResult(i, 0);
private final PendingIntent retrievePlaybackAction(final String action) { final ComponentName serviceName = new ComponentName(this, MusicService.class); Intent intent = new Intent(action); intent.setComponent(serviceName); return PendingIntent.getService(this, 0, intent, 0); }
public static void triggerMessageListWidgetUpdate(Context context) { Context appContext = context.getApplicationContext(); AppWidgetManager widgetManager = AppWidgetManager.getInstance(appContext); ComponentName widget = new ComponentName(appContext, MessageListWidgetProvider.class); int[] widgetIds = widgetManager.getAppWidgetIds(widget); Intent intent = new Intent(context, MessageListWidgetProvider.class); intent.setAction(ACTION_UPDATE_MESSAGE_LIST); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds); context.sendBroadcast(intent); }
private void storeAndReplaceOriginalComponentName(Intent intent, String origPackageName, String origClassName, String stubClassName) { final ComponentName origComponentName = new ComponentName(origPackageName, origClassName); ShareIntentUtil.fixIntentClassLoader(intent, mContext.getClassLoader()); intent.putExtra(EnvConsts.INTENT_EXTRA_OLD_COMPONENT, origComponentName); final ComponentName stubComponentName = new ComponentName(origPackageName, stubClassName); intent.setComponent(stubComponentName); }
private final PendingIntent retrievePlaybackAction(final String action) { final ComponentName serviceName = new ComponentName(this, MediaService.class); Intent intent = new Intent(action); intent.setComponent(serviceName); return PendingIntent.getService(this, 0, intent, 0); }
public static void runResultService(Context context, PatchResult result, String resultServiceClass) { if (resultServiceClass == null) { throw new TinkerRuntimeException("resultServiceClass is null."); } try { if (!TinkerJobIntentService.class.isAssignableFrom(Class.forName(resultServiceClass))) { throw new TinkerRuntimeException("on tinker version " + BuildConfig.TINKER_VERSION + " result service class must inherit from TinkerJobIntentService."); } } catch (ClassNotFoundException e) { throw new TinkerRuntimeException("cannot find result service class: " + resultServiceClass, e); } try { Intent intent = new Intent(); intent.setClassName(context, resultServiceClass); intent.putExtra(RESULT_EXTRA, result); enqueueWork(context, new ComponentName(context, resultServiceClass), JOB_ID, intent); } catch (Throwable throwable) { TinkerLog.e(TAG, "run result service fail, exception:" + throwable); } }
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&daddr=51.448,-0.972")); intent.setComponent(new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity")); startActivity(intent);
public static boolean openAppActivity(Context context, String packageName, String activityName) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); ComponentName cn = new ComponentName(packageName, activityName); intent.setComponent(cn); try { context.startActivity(intent); return true; } catch (Exception e) { return false; } }
private NotificationItem(int id, String title, String desc) { super(id, title, desc); Intent[] intents = new Intent[2]; intents[0] = Intent.makeMainActivity(new ComponentName(DemoApplication.CONTEXT, MainActivity.class)); intents[1] = new Intent(DemoApplication.CONTEXT, NotificationSampleActivity.class); this.pendingIntent = PendingIntent.getActivities(DemoApplication.CONTEXT, 0, intents, PendingIntent.FLAG_UPDATE_CURRENT); builder = new NotificationCompat. Builder(FileDownloadHelper.getAppContext()); builder.setDefaults(Notification.DEFAULT_LIGHTS) .setOngoing(true) .setPriority(NotificationCompat.PRIORITY_MIN) .setContentTitle(getTitle()) .setContentText(desc) .setContentIntent(pendingIntent) .setSmallIcon(R.mipmap.ic_launcher); }
Intent internetIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); internetIntent.setComponent(new ComponentName("com.android.browser","com.android.browser.BrowserActivity")); internetIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(internetIntent);
Intent res = new Intent(); String mPackage = "com.your.package"; String mClass = ".actYouAreLaunching"; res.setComponent(new ComponentName(mPackage,mPackage+mClass)); startActivity(res);
private NotificationItem(int id, String title, String desc) { super(id, title, desc); Intent[] intents = new Intent[2]; intents[0] = Intent.makeMainActivity(new ComponentName(DemoApplication.CONTEXT, MainActivity.class)); intents[1] = new Intent(DemoApplication.CONTEXT, NotificationSampleActivity.class); this.pendingIntent = PendingIntent.getActivities(DemoApplication.CONTEXT, 0, intents, PendingIntent.FLAG_UPDATE_CURRENT); builder = new NotificationCompat. Builder(FileDownloadHelper.getAppContext()); builder.setDefaults(Notification.DEFAULT_LIGHTS) .setOngoing(true) .setPriority(NotificationCompat.PRIORITY_MIN) .setContentTitle(getTitle()) .setContentText(desc) .setContentIntent(pendingIntent) .setSmallIcon(R.mipmap.ic_launcher); }
String className = clockImpls[i][2]; try { ComponentName cn = new ComponentName(packageName, className); ActivityInfo aInfo = packageManager.getActivityInfo(cn, PackageManager.GET_META_DATA); alarmClockIntent.setComponent(cn); debug("Found " + vendor + " --> " + packageName + "/" + className); foundClockImpl = true;
public Intent intentForPosition(int position) { DisplayResolveInfo dri = mList.get(position); Intent intent = new Intent(dri.origIntent != null ? dri.origIntent : mIntent); intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); ActivityInfo ai = dri.ri.activityInfo; intent.setComponent(new ComponentName( ai.applicationInfo.packageName, ai.name)); return intent; }
@Test public void constructor_shouldSetComponentAndActionAndData() { Intent intent = new Intent( "roboaction", Uri.parse("http://www.robolectric.org"), ApplicationProvider.getApplicationContext(), Activity.class); assertThat(intent.getComponent()).isEqualTo(new ComponentName("org.robolectric", "android.app.Activity")); assertThat(intent.getAction()).isEqualTo("roboaction"); assertThat(intent.getData()).isEqualTo(Uri.parse("http://www.robolectric.org")); }
for (ActivityInfo activityInfo : pi.activities) { if (activityInfo.name.equals(MANAGER_OUT_CLS)) { comp = new ComponentName(PKG, MANAGER_OUT_CLS); intent.setComponent(comp);
@Override public void onReceive(Context context, Intent intent) { // if (MusicPlayer.isPlaying()) { Intent activityIntent = new Intent(context.getApplicationContext(), PlayingActivity.class); activityIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); context.getApplicationContext().startActivity(activityIntent); Intent intent1 = new Intent(); intent1.setComponent(new ComponentName("com.wm.remusic", "com.wm.remusic.activity.PlayingActivity.class")); context.sendBroadcast(intent1); // } }
@Test public void queryIntentActivities_DisabledComponentViaPmImplicitIntent() throws Exception { Uri uri = Uri.parse("content://testhost1.com:1/testPath/test.jpeg"); Intent i = new Intent(Intent.ACTION_VIEW); i.addCategory(Intent.CATEGORY_DEFAULT); i.setDataAndType(uri, "image/jpeg"); ComponentName componentToDisable = new ComponentName( ApplicationProvider.getApplicationContext(), "org.robolectric.shadows.TestActivity"); packageManager.setComponentEnabledSetting( componentToDisable, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(i, 0); assertThat(resolveInfos).isEmpty(); }