List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:com.fvd.nimbus.PaintActivity.java
@Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub Intent ip; drawer.closeDrawer(GravityCompat.START); switch (arg2) { case 0:/*from www . j a v a 2 s. c o m*/ getPhoto(); break; case 1: getPicture(); break; case 2: ip = new Intent(); ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.BrowseActivity"); startActivity(ip); finish(); break; case 3: ip = new Intent(); ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.ChoosePDFActivity"); startActivity(ip); finish(); break; default: break; } }
From source file:com.Beat.RingdroidEditActivity.java
protected void reset(String path) { String filename = path;//from ww w .ja va2 s. c o m try { Intent intent = new Intent(Intent.ACTION_EDIT, Uri.parse(filename)); intent.putExtra("was_get_content_intent", mWasGetContentIntent); //true should be mWasGetContentIntent intent.setClassName("com.Beat", "com.Beat.RingdroidEditActivity"); startActivity(intent); //1 should be REQUEST_CODE_EDIT this.finish(); } catch (Exception e) { return; } }
From source file:com.fvd.nimbus.BrowseActivity.java
public void screenCapture(/*boolean full*/) { View v = super.findViewById(R.id.wvWrapper); /*if(full) v = super.findViewById(R.id.wv); else v = super.findViewById(R.id.wvWrapper);*/ if (v != null) { Bitmap bm = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.RGB_565); v.draw(new Canvas(bm)); if (bm != null) { try { /*String filename=String.valueOf(System.currentTimeMillis())+"-tmp.png"; File file = new File(appSettings.getInstance(null).getSavingPath(),filename); file.createNewFile();/*from w w w .ja v a 2s .co m*/ FileOutputStream ostream = new FileOutputStream(file); bm.compress(CompressFormat.PNG, 100, ostream); ostream.flush(); ostream.close();*/ String filename = appSettings.saveTempBitmap(bm); if (filename != null && filename.length() > 0) { Intent iPaint = new Intent(); /*ByteArrayOutputStream stream = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray();*/ //iPaint.putExtra("shot", byteArray); Toast.makeText(getApplicationContext(), "Saved as " + filename, Toast.LENGTH_LONG).show(); iPaint.putExtra("temp", true); iPaint.putExtra("path", filename); iPaint.putExtra("domain", getDomainName(lastUrl)); iPaint.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity"); startActivity(iPaint); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } else Toast.makeText(getApplicationContext(), "failed", Toast.LENGTH_LONG).show(); } else Toast.makeText(getApplicationContext(), "not found", Toast.LENGTH_LONG).show(); }
From source file:org.mariotaku.twidere.util.Utils.java
public static void addIntentToSubMenu(final Context context, final SubMenu menu, final Intent query_intent) { if (context == null || menu == null || query_intent == null) return;/* ww w. j a va 2s. c o m*/ final PackageManager pm = context.getPackageManager(); final List<ResolveInfo> activities = pm.queryIntentActivities(query_intent, 0); for (final ResolveInfo info : activities) { final Intent intent = new Intent(query_intent); intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); menu.add(info.loadLabel(pm)).setIcon(info.loadIcon(pm)).setIntent(intent); } }
From source file:org.uguess.android.sysinfo.ApplicationManager.java
void handleAction(final AppInfoHolder ai, int action) { Activity ctx = getActivity();/*from w w w . ja v a2 s .com*/ String pkgName = ai.appInfo.packageName; switch (action) { case ACTION_MENU: OnClickListener listener = new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // bypass the 'showMenu' action offset int action = which + 1; handleAction(ai, action); } }; new AlertDialog.Builder(ctx).setTitle(R.string.actions) .setItems(new CharSequence[] { getString(R.string.manage), getString(R.string.run), getString(R.string.search_market), getString(R.string.details) }, listener) .create().show(); break; case ACTION_MANAGE: Intent it = new Intent(Intent.ACTION_VIEW); it.setClassName("com.android.settings", //$NON-NLS-1$ "com.android.settings.InstalledAppDetails"); //$NON-NLS-1$ it.putExtra("com.android.settings.ApplicationPkgName", pkgName); //$NON-NLS-1$ // this is for Froyo it.putExtra("pkg", pkgName); //$NON-NLS-1$ List<ResolveInfo> acts = ctx.getPackageManager().queryIntentActivities(it, 0); if (acts.size() > 0) { startActivity(it); } else { // for ginger bread it = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", //$NON-NLS-1$ Uri.fromParts("package", pkgName, null)); //$NON-NLS-1$ acts = ctx.getPackageManager().queryIntentActivities(it, 0); if (acts.size() > 0) { startActivity(it); } else { Log.d(ApplicationManager.class.getName(), "Failed to resolve activity for InstalledAppDetails"); //$NON-NLS-1$ } } break; case ACTION_LAUNCH: if (!pkgName.equals(ctx.getPackageName())) { it = new Intent("android.intent.action.MAIN"); //$NON-NLS-1$ it.addCategory(Intent.CATEGORY_LAUNCHER); acts = ctx.getPackageManager().queryIntentActivities(it, 0); if (acts != null) { boolean started = false; for (int i = 0, size = acts.size(); i < size; i++) { ResolveInfo ri = acts.get(i); if (pkgName.equals(ri.activityInfo.packageName)) { it.setClassName(ri.activityInfo.packageName, ri.activityInfo.name); it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); try { startActivity(it); started = true; } catch (Exception e) { Log.e(ApplicationManager.class.getName(), "Cannot start activity: " + pkgName, //$NON-NLS-1$ e); } break; } } if (!started) { Util.shortToast(ctx, R.string.run_failed); } } } break; case ACTION_SEARCH: it = new Intent(Intent.ACTION_VIEW); it.setData(Uri.parse("market://search?q=pname:" + pkgName)); //$NON-NLS-1$ it = Intent.createChooser(it, null); startActivity(it); break; case ACTION_DETAILS: ApplicationInfo appInfo = ai.appInfo; String installDate; String fileSize; if (appInfo.sourceDir != null) { File f = new File(appInfo.sourceDir); installDate = DateUtils.formatDateTime(ctx, f.lastModified(), DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); fileSize = Formatter.formatFileSize(ctx, f.length()); } else { installDate = fileSize = getString(R.string.unknown); } StringBuffer sb = new StringBuffer().append("<small>") //$NON-NLS-1$ .append(getString(R.string.pkg_name)).append(": ") //$NON-NLS-1$ .append(appInfo.packageName).append("<br>") //$NON-NLS-1$ .append(getString(R.string.version_code)).append(": ") //$NON-NLS-1$ .append(ai.versionCode).append("<br>") //$NON-NLS-1$ .append(getString(R.string.target_sdk)).append(": ") //$NON-NLS-1$ .append(Util.getTargetSdkVersion(ctx, appInfo)).append("<br>") //$NON-NLS-1$ .append(getString(R.string.uid)).append(": ") //$NON-NLS-1$ .append(appInfo.uid).append("<br>") //$NON-NLS-1$ .append(getString(R.string.file_size)).append(": ") //$NON-NLS-1$ .append(fileSize).append("<br>") //$NON-NLS-1$ .append(getString(R.string.public_source)).append(": ") //$NON-NLS-1$ .append(appInfo.publicSourceDir).append("<br>") //$NON-NLS-1$ .append(getString(R.string.source)).append(": ") //$NON-NLS-1$ .append(appInfo.sourceDir).append("<br>") //$NON-NLS-1$ .append(getString(R.string.data)).append(": ") //$NON-NLS-1$ .append(appInfo.dataDir).append("<br>") //$NON-NLS-1$ .append(getString(R.string.installed_date)).append(": ") //$NON-NLS-1$ .append(installDate).append("<br>") //$NON-NLS-1$ .append(getString(R.string.process)).append(": ") //$NON-NLS-1$ .append(appInfo.processName).append("<br>") //$NON-NLS-1$ .append(getString(R.string.app_class)).append(": ") //$NON-NLS-1$ .append(appInfo.className == null ? "" //$NON-NLS-1$ : appInfo.className) .append("<br>") //$NON-NLS-1$ .append(getString(R.string.task_affinity)).append(": ") //$NON-NLS-1$ .append(appInfo.taskAffinity).append("<br>") //$NON-NLS-1$ .append(getString(R.string.permission)).append(": ") //$NON-NLS-1$ .append(appInfo.permission == null ? "" //$NON-NLS-1$ : appInfo.permission) .append("<br>") //$NON-NLS-1$ .append(getString(R.string.flags)).append(": ") //$NON-NLS-1$ .append(appInfo.flags).append("<br>") //$NON-NLS-1$ .append(getString(R.string.enabled)).append(": ") //$NON-NLS-1$ .append(appInfo.enabled).append("<br>") //$NON-NLS-1$ .append(getString(R.string.manage_space_ac)).append(": ") //$NON-NLS-1$ .append(appInfo.manageSpaceActivityName == null ? "" //$NON-NLS-1$ : appInfo.manageSpaceActivityName) .append("</small>"); //$NON-NLS-1$ new AlertDialog.Builder(ctx).setTitle(ai.label == null ? appInfo.packageName : ai.label) .setNeutralButton(R.string.close, null).setMessage(Html.fromHtml(sb.toString())).create() .show(); break; } }
From source file:com.androzic.Androzic.java
public void initializeOnlineMapProviders() { PackageManager packageManager = getPackageManager(); Intent initializationIntent = new Intent("com.androzic.map.online.provider.action.INITIALIZE"); // enumerate online map providers List<ResolveInfo> providers = packageManager.queryBroadcastReceivers(initializationIntent, 0); for (ResolveInfo provider : providers) { // send initialization broadcast, we send it directly instead of sending // one broadcast for all plugins to wake up stopped plugins: // http://developer.android.com/about/versions/android-3.1.html#launchcontrols Intent intent = new Intent(); intent.setClassName(provider.activityInfo.packageName, provider.activityInfo.name); intent.setAction(initializationIntent.getAction()); sendBroadcast(intent);// ww w .j a v a 2 s . co m List<TileProvider> tileProviders = TileProviderFactory.fromPlugin(packageManager, provider); for (TileProvider tileProvider : tileProviders) { tileProvider.tileExpiration = onlineMapTileExpiration; } onlineMaps.addAll(tileProviders); } }
From source file:com.androzic.Androzic.java
public void initializePlugins() { PackageManager packageManager = getPackageManager(); List<ResolveInfo> plugins; Intent initializationIntent = new Intent("com.androzic.plugins.action.INITIALIZE"); // enumerate initializable plugins plugins = packageManager.queryBroadcastReceivers(initializationIntent, 0); for (ResolveInfo plugin : plugins) { // send initialization broadcast, we send it directly instead of sending // one broadcast for all plugins to wake up stopped plugins: // http://developer.android.com/about/versions/android-3.1.html#launchcontrols Intent intent = new Intent(); intent.setClassName(plugin.activityInfo.packageName, plugin.activityInfo.name); intent.setAction(initializationIntent.getAction()); sendBroadcast(intent);// ww w . jav a 2 s .c om } // enumerate plugins with preferences plugins = packageManager.queryIntentActivities(new Intent("com.androzic.plugins.preferences"), 0); for (ResolveInfo plugin : plugins) { Intent intent = new Intent(); intent.setClassName(plugin.activityInfo.packageName, plugin.activityInfo.name); pluginPreferences.put(plugin.activityInfo.loadLabel(packageManager).toString(), intent); } // enumerate plugins with views plugins = packageManager.queryIntentActivities(new Intent("com.androzic.plugins.view"), 0); for (ResolveInfo plugin : plugins) { // get menu icon Drawable icon = null; try { Resources resources = packageManager .getResourcesForApplication(plugin.activityInfo.applicationInfo); int id = resources.getIdentifier("ic_menu_view", "drawable", plugin.activityInfo.packageName); if (id != 0) icon = resources.getDrawable(id); } catch (Resources.NotFoundException e) { e.printStackTrace(); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } Intent intent = new Intent(); intent.setClassName(plugin.activityInfo.packageName, plugin.activityInfo.name); Pair<Drawable, Intent> pair = new Pair<>(icon, intent); pluginViews.put(plugin.activityInfo.loadLabel(packageManager).toString(), pair); } }
From source file:org.uguess.android.sysinfo.ProcessManager.java
void handleAction(final ProcessItem rap, int action) { Activity ctx = getActivity();// w w w.ja v a2 s . c o m switch (action) { case ACTION_END: if (!ignoreList.contains(rap.procInfo.processName) && !rap.sys) { ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); String self = ctx.getPackageName(); if (self.equals(rap.procInfo.processName)) { Util.killSelf(handler, ctx, am, self); } else { endProcess(am, rap.procInfo.pkgList, self); handler.removeCallbacks(task); handler.post(task); } } break; case ACTION_END_OTHERS: endAllExcept(rap.procInfo.processName); break; case ACTION_SWITCH: String pkgName = rap.procInfo.processName; if (!pkgName.equals(ctx.getPackageName())) { Intent it = new Intent("android.intent.action.MAIN"); //$NON-NLS-1$ it.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> acts = ctx.getPackageManager().queryIntentActivities(it, 0); if (acts != null) { boolean started = false; for (int i = 0, size = acts.size(); i < size; i++) { ResolveInfo ri = acts.get(i); if (pkgName.equals(ri.activityInfo.packageName)) { it.setClassName(ri.activityInfo.packageName, ri.activityInfo.name); it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); try { startActivity(it); started = true; } catch (Exception e) { Log.e(ProcessManager.class.getName(), "Cannot start activity: " + pkgName, //$NON-NLS-1$ e); } break; } } if (!started) { Util.shortToast(ctx, R.string.error_switch_task); } } } break; case ACTION_IGNORE: if (!ignoreList.contains(rap.procInfo.processName) && !rap.sys) { ignoreList.add(rap.procInfo.processName); setIgnoreList(ignoreList); if (IGNORE_ACTION_HIDDEN == Util.getIntOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_IGNORE_ACTION, IGNORE_ACTION_HIDDEN)) { handler.removeCallbacks(task); handler.post(task); } } break; case ACTION_DETAILS: String[] status = readProcStatus(rap.procInfo.pid); StringBuffer sb = new StringBuffer().append("<small>") //$NON-NLS-1$ .append(getString(R.string.proc_name)).append(": ") //$NON-NLS-1$ .append(rap.procInfo.processName).append("<br>") //$NON-NLS-1$ .append(getString(R.string.pid)).append(": ") //$NON-NLS-1$ .append(rap.procInfo.pid).append("<br>") //$NON-NLS-1$ .append(getString(R.string.uid)).append(": ") //$NON-NLS-1$ .append(status == null ? "" : status[1]) //$NON-NLS-1$ .append("<br>") //$NON-NLS-1$ .append(getString(R.string.gid)).append(": ") //$NON-NLS-1$ .append(status == null ? "" : status[2]) //$NON-NLS-1$ .append("<br>") //$NON-NLS-1$ .append(getString(R.string.state)).append(": ") //$NON-NLS-1$ .append(status == null ? "" : status[0]) //$NON-NLS-1$ .append("<br>") //$NON-NLS-1$ .append(getString(R.string.threads)).append(": ") //$NON-NLS-1$ .append(status == null ? "" : status[3]) //$NON-NLS-1$ .append("<br>") //$NON-NLS-1$ .append(getString(R.string.importance)).append(": ") //$NON-NLS-1$ .append(rap.procInfo.importance).append("<br>LRU: ") //$NON-NLS-1$ .append(rap.procInfo.lru).append("<br>") //$NON-NLS-1$ .append(getString(R.string.pkg_name)).append(": "); //$NON-NLS-1$ if (rap.procInfo.pkgList != null) { int i = 0; for (String pkg : rap.procInfo.pkgList) { if (pkg != null) { if (i > 0) { sb.append(", "); //$NON-NLS-1$ } sb.append(pkg); i++; } } } sb.append("</small>"); //$NON-NLS-1$ new AlertDialog.Builder(ctx).setTitle(rap.label == null ? rap.procInfo.processName : rap.label) .setNeutralButton(R.string.close, null).setMessage(Html.fromHtml(sb.toString())).create() .show(); break; case ACTION_MENU: final boolean protect = ignoreList.contains(rap.procInfo.processName) || rap.sys; OnClickListener listener = new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // bypass the 'showMenu' action offset int action = which + 1; if (!protect || (action != ACTION_END && action != ACTION_IGNORE)) { handleAction(rap, action); } } }; new AlertDialog.Builder( ctx).setTitle(R.string.actions) .setItems( new CharSequence[] { getString(R.string.switch_to), protect ? Html.fromHtml("<font color=\"#848484\">" //$NON-NLS-1$ + getString(R.string.end_task) + "</font>") //$NON-NLS-1$ : getString(R.string.end_task), getString(R.string.end_others), protect ? Html.fromHtml("<font color=\"#848484\">" //$NON-NLS-1$ + getString(R.string.ignore) + "</font>") //$NON-NLS-1$ : getString(R.string.ignore), getString(R.string.details) }, listener) .create().show(); break; } }
From source file:com.bookkos.bircle.CaptureActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); switch (item.getItemId()) { case R.id.menu_group_select: intent.setClassName(this, GroupSelectActivity.class.getName()); startActivity(intent);// ww w . ja v a2 s .c o m break; case R.id.menu_web_view: intent.setClassName(this, WebViewActivity.class.getName()); startActivity(intent); break; case R.id.menu_logout: logout(); break; case R.id.menu_open_source_license: openSourceLicenseDialog(); break; default: return super.onOptionsItemSelected(item); } return true; }
From source file:com.android.mms.ui.MessageUtils.java
public static void recordSound(Activity activity, int requestCode, long sizeLimit) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(MmsContentType.AUDIO_AMR); intent.setClassName("com.android.soundrecorder", "com.android.soundrecorder.SoundRecorder"); intent.putExtra(android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES, sizeLimit); activity.startActivityForResult(intent, requestCode); }