List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:com.example.android.bluetoothchat.BluetoothChatFragment2.java
private static void gearVRforVideofunctionality(Context context, String mVRfilePath) { PackageInfo svrInstalled;/* w ww . j a v a 2 s. c om*/ String SVR_PACKAGE_NAME_LOCAL = VR_VIDEO_PKG_NAME; String SVR_ACTIVITY_NAME = VR_VIDEO_ACTIVITY_NAME; try { svrInstalled = context.getPackageManager().getPackageInfo(SVR_PACKAGE_NAME_LOCAL, VR_VIEWTYPE_ALBUM); } catch (PackageManager.NameNotFoundException e) { svrInstalled = null; } if (svrInstalled != null) { Uri uri = Uri.parse("file://" + mVRfilePath); Intent intent = new Intent(); intent.setClassName(SVR_PACKAGE_NAME_LOCAL, SVR_ACTIVITY_NAME); intent.setData(uri); // intent.putExtra("wait_title", context.getString(C0804R.string.SS_INSERT_DEVICE_INTO_GEAR_VR_HEADER_ABB)); // intent.putExtra("wait_message", context.getString(C0804R.string.f148xfc67daff)); // intent.setFlags(268500992); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); ((Activity) context).overridePendingTransition(VR_VIEWTYPE_ALBUM, VR_VIEWTYPE_ALBUM); return; } }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open App Detail page/*from w w w. ja v a 2s .c om*/ */ public static void openAppDetail(String packageName, Context context) { Intent intent = new Intent(); final int apiLevel = Build.VERSION.SDK_INT; if (apiLevel >= 9) { intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", packageName, null); intent.setData(uri); } else { final String appPkgName = (apiLevel == 8 ? "pkg" : "com.android.settings.ApplicationPkgName"); intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra(appPkgName, packageName); } context.startActivity(intent); }
From source file:com.example.android.bluetoothchat.BluetoothChatFragment2.java
public static void startVrGallery2(Context context, int type, String path, int currentSeek) { PackageInfo svrInstalled;/*from w w w . jav a2s . co m*/ String SVR_PACKAGE_NAME_LOCAL = VR_GALLERY2_PKG_NAME; String SVR_ACTIVITY_NAME = VR_GALLERY2_ACTIVITY_NAME; try { svrInstalled = context.getPackageManager().getPackageInfo(SVR_PACKAGE_NAME_LOCAL, VR_VIEWTYPE_ALBUM); } catch (PackageManager.NameNotFoundException e) { svrInstalled = null; } if (svrInstalled != null) { Uri uri = Uri.parse("file://" + path); Intent intent = new Intent(); intent.setClassName(SVR_PACKAGE_NAME_LOCAL, SVR_ACTIVITY_NAME); intent.setData(uri); intent.putExtra("viewmode", type); // intent.putExtra("wait_title", "Wait Title"); // intent.putExtra("wait_message", "Wait Message"); if (currentSeek > 0) { intent.putExtra("seek", currentSeek); } // intent.setFlags(268500992); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); ((Activity) context).overridePendingTransition(VR_VIEWTYPE_ALBUM, VR_VIEWTYPE_ALBUM); return; } }
From source file:Main.java
public static void mail(Activity activity, String email, String subject, String content) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); intent.putExtra(Intent.EXTRA_SUBJECT, subject); if (content != null) { intent.putExtra(Intent.EXTRA_TEXT, content); }/* w w w . j a v a 2s . com*/ final PackageManager manager = activity.getPackageManager(); final List<ResolveInfo> matches = manager.queryIntentActivities(intent, 0); for (ResolveInfo info : matches) { if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); } else if (info.activityInfo.packageName.endsWith(".email") || info.activityInfo.name.toLowerCase().contains("email")) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); } } activity.startActivity(intent); }
From source file:com.google.android.gcm.GCMBaseIntentService.java
/** * Called from the broadcast receiver.//from w ww . j a v a2s .com * <p> * Will process the received intent, call handleMessage(), registered(), * etc. in background threads, with a wake lock, while keeping the service * alive. */ static void runIntentInService(Context context, Intent intent, String className) { synchronized (LOCK) { if (sWakeLock == null) { // This is called from BroadcastReceiver, there is no init. PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); sWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_KEY); } } Log.v(TAG, "Acquiring wakelock"); sWakeLock.acquire(); intent.setClassName(context, className); context.startService(intent); }
From source file:com.linkbubble.MainApplication.java
public static Intent getStoreIntent(Context context, String storeProUrl) { PackageManager manager = context.getPackageManager(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(storeProUrl)); List<ResolveInfo> infos = manager.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER); for (ResolveInfo info : infos) { IntentFilter filter = info.filter; if (filter != null && filter.hasAction(Intent.ACTION_VIEW) && filter.hasCategory(Intent.CATEGORY_BROWSABLE)) { if (info.activityInfo.packageName.equals(BuildConfig.STORE_PACKAGE)) { Intent result = new Intent(Intent.ACTION_VIEW); result.setClassName(info.activityInfo.packageName, info.activityInfo.name); result.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); result.setData(Uri.parse(storeProUrl)); return result; }//ww w . j a va2s . c o m } } return null; }
From source file:fm.smart.r1.ItemActivity.java
static void setSound(ImageView sound_icon, final String sound_url, final Context context, final int type_id, final String artifact_id, final String to_record) { if (!TextUtils.isEmpty(sound_url)) { OnClickListener sound_listener = new OnClickListener() { public void onClick(View v) {// TODO removed temporarily MediaUtility.playSound(sound_url, ItemListActivity.mMediaPlayer, context); }//from w ww. j av a 2s. com }; sound_icon.setOnClickListener(sound_listener); sound_icon .setImageBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.active_sound)); } else { if (type_id == R.id.response_sound || type_id == R.id.translation_sound) { sound_icon.setVisibility(View.INVISIBLE); } else { sound_icon.setImageBitmap( BitmapFactory.decodeResource(context.getResources(), R.drawable.inactive_sound_add)); OnClickListener listener = new OnClickListener() { public void onClick(View v) { // TODO removed temporarily Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(context, CreateSoundActivity.class.getName()); AndroidUtils.putExtra(intent, "item_id", (String) item.getId()); AndroidUtils.putExtra(intent, "to_record", to_record); AndroidUtils.putExtra(intent, "id", artifact_id); AndroidUtils.putExtra(intent, "sound_type", Integer.toString(type_id)); context.startActivity(intent); } }; sound_icon.setOnClickListener(listener); } } }
From source file:Main.java
public static void shareToGMail(Context context, String[] email, String subject, String content) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.putExtra(Intent.EXTRA_EMAIL, email); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content); final PackageManager pm = context.getPackageManager(); final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0); ResolveInfo best = null;/*from w ww.ja va 2s .c o m*/ for (final ResolveInfo info : matches) if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) best = info; if (best != null) emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name); context.startActivity(emailIntent); }
From source file:com.linkbubble.MainApplication.java
public static boolean loadIntent(Context context, String packageName, String className, String urlAsString, long urlLoadStartTime, boolean toastOnError) { Intent openIntent = new Intent(Intent.ACTION_VIEW); try {/*from ww w.ja va 2s. c o m*/ openIntent.setClassName(packageName, className); openIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); openIntent.setData(Uri.parse(urlAsString)); context.startActivity(openIntent); //Log.d(TAG, "redirect to app: " + resolveInfo.loadLabel(context.getPackageManager()) + ", url:" + url); if (urlLoadStartTime > -1) { Settings.get().trackLinkLoadTime(System.currentTimeMillis() - urlLoadStartTime, Settings.LinkLoadType.AppRedirectBrowser, urlAsString); } CrashTracking.log("MainApplication.loadIntent()"); return true; } catch (Exception ex) { // We want to catch SecurityException || ActivityNotFoundException openIntent = new Intent(Intent.ACTION_VIEW); openIntent.setPackage(packageName); openIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); openIntent.setData(Uri.parse(urlAsString)); try { context.startActivity(openIntent); if (urlLoadStartTime > -1) { Settings.get().trackLinkLoadTime(System.currentTimeMillis() - urlLoadStartTime, Settings.LinkLoadType.AppRedirectBrowser, urlAsString); } CrashTracking.log("MainApplication.loadIntent() [2]"); return true; } catch (SecurityException ex2) { if (toastOnError) { Toast.makeText(context, R.string.unable_to_launch_app, Toast.LENGTH_SHORT).show(); } return false; } catch (ActivityNotFoundException activityNotFoundException) { if (toastOnError) { Toast.makeText(context, R.string.unable_to_launch_app, Toast.LENGTH_SHORT).show(); } return false; } } }
From source file:com.linkbubble.util.Util.java
static public Intent getSendIntent(String packageName, String className, String urlAsString) { // TODO: Retrieve the class name below from the app in case Twitter ever change it. Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.setClassName(packageName, className); if (packageName.equals(Constant.POCKET_PACKAGE_NAME)) { // Stop pocket spawning when links added intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } else {//from w ww . jav a2s .c om intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } intent.putExtra(Intent.EXTRA_TEXT, urlAsString); String title = MainApplication.sTitleHashMap != null ? MainApplication.sTitleHashMap.get(urlAsString) : null; if (title != null) { intent.putExtra(Intent.EXTRA_SUBJECT, title); } return intent; }