List of usage examples for android.app Activity getPackageName
@Override
public String getPackageName()
From source file:com.remobile.file.FileUtils.java
public void initialize() { this.filesystems = new ArrayList<Filesystem>(); String tempRoot = null;/*from w w w . j a v a 2s .c o m*/ String persistentRoot = null; Activity activity = cordova.getActivity(); String packageName = activity.getPackageName(); String location = "internal"; tempRoot = activity.getCacheDir().getAbsolutePath(); if ("internal".equalsIgnoreCase(location)) { persistentRoot = activity.getFilesDir().getAbsolutePath() + "/files/"; this.configured = true; } else if ("compatibility".equalsIgnoreCase(location)) { /* * Fall-back to compatibility mode -- this is the logic implemented in * earlier versions of this plugin, and should be maintained here so * that apps which were originally deployed with older versions of the * plugin can continue to provide access to files stored under those * versions. */ if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { persistentRoot = Environment.getExternalStorageDirectory().getAbsolutePath(); tempRoot = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + packageName + "/cache/"; } else { persistentRoot = "/data/data/" + packageName; } this.configured = true; } if (this.configured) { // Create the directories if they don't exist. File tmpRootFile = new File(tempRoot); File persistentRootFile = new File(persistentRoot); tmpRootFile.mkdirs(); persistentRootFile.mkdirs(); // Register initial filesystems // Note: The temporary and persistent filesystems need to be the first two // registered, so that they will match window.TEMPORARY and window.PERSISTENT, // per spec. this.registerFilesystem( new LocalFilesystem("temporary", this.getContext(), this.getResourceApi(), tmpRootFile)); this.registerFilesystem(new LocalFilesystem("persistent", this.getContext(), this.getResourceApi(), persistentRootFile)); this.registerFilesystem(new ContentFilesystem(this.getContext(), this.getResourceApi())); this.registerFilesystem(new AssetFilesystem(this.getContext().getAssets(), this.getResourceApi())); registerExtraFileSystems(getExtraFileSystemsPreference(activity), getAvailableFileSystems(activity)); // Initialize static plugin reference for deprecated getEntry method if (filePlugin == null) { FileUtils.filePlugin = this; } } else { Log.e(LOG_TAG, "File plugin configuration error: Please set AndroidPersistentFileLocation in config.xml to one of \"internal\" (for new applications) or \"compatibility\" (for compatibility with previous versions)"); activity.finish(); } }
From source file:com.vuze.android.remote.AppPreferences.java
public void showRateDialog(final Activity mContext) { if (!shouldShowRatingReminder()) { return;//from w w w.ja v a 2 s. c om } // skip showing if they are adding a torrent (or anything else) Intent intent = mContext.getIntent(); if (intent != null) { Uri data = intent.getData(); if (data != null) { return; } } // even if something goes wrong, we want to set that we asked, so // it doesn't continue to pop up setAskedRating(); Dialog dialog = new Dialog(mContext); AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.ask_rating_message).setCancelable(false) .setPositiveButton(R.string.rate_now, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final String appPackageName = mContext.getPackageName(); try { mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); } VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskStoreClick", null); } }).setNeutralButton(R.string.later, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(R.string.no_thanks, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setNeverAskRatingAgain(); } }); dialog = builder.create(); VuzeEasyTracker.getInstance(mContext).sendEvent("uiAction", "Rating", "AskShown", null); dialog.show(); }
From source file:widgets.Graphical_List.java
@SuppressLint("HandlerLeak") public Graphical_List(tracerengine Trac, Activity context, int id, int dev_id, String name, String type, String address, final String state_key, String url, final String usage, int period, int update, int widgetSize, int session_type, final String parameters, String model_id, int place_id, String place_type, SharedPreferences params) { super(context, Trac, id, name, "", usage, widgetSize, session_type, place_id, place_type, mytag, container); this.Tracer = Trac; this.context = context; this.dev_id = dev_id; this.id = id; this.usage = usage; this.address = address; //this.type = type; this.state_key = state_key; this.update = update; this.wname = name; this.url = url; String[] model = model_id.split("\\."); this.type = model[0]; this.place_id = place_id; this.place_type = place_type; this.params = params; packageName = context.getPackageName(); this.myself = this; this.session_type = session_type; this.parameters = parameters; setOnLongClickListener(this); setOnClickListener(this); mytag = "Graphical_List (" + dev_id + ")"; login = params.getString("http_auth_username", null); password = params.getString("http_auth_password", null); //state key/*from w w w .j a v a 2s .c o m*/ state_key_view = new TextView(context); state_key_view.setText(state_key); state_key_view.setTextColor(Color.parseColor("#333333")); //value value = new TextView(context); value.setTextSize(28); value.setTextColor(Color.BLACK); animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(1000); if (with_list) { //Exploit parameters JSONObject jparam = null; String command; JSONArray commandValues = null; try { jparam = new JSONObject(parameters.replaceAll(""", "\"")); command = jparam.getString("command"); commandValues = jparam.getJSONArray("commandValues"); Tracer.e(mytag, "Json command :" + commandValues); } catch (Exception e) { command = ""; commandValues = null; Tracer.e(mytag, "Json command error " + e.toString()); } if (commandValues != null) { if (commandValues.length() > 0) { if (known_values != null) known_values = null; known_values = new String[commandValues.length()]; for (int i = 0; i < commandValues.length(); i++) { try { known_values[i] = commandValues.getString(i); } catch (Exception e) { known_values[i] = "???"; } } } } //list of choices listeChoices = new ListView(context); listItem = new ArrayList<HashMap<String, String>>(); list_usable_choices = new Vector<String>(); for (int i = 0; i < known_values.length; i++) { list_usable_choices.add(getStringResourceByName(known_values[i])); HashMap<String, String> map = new HashMap<String, String>(); map.put("choice", getStringResourceByName(known_values[i])); map.put("cmd_to_send", known_values[i]); listItem.add(map); } SimpleAdapter adapter_map = new SimpleAdapter(getContext(), listItem, R.layout.item_choice, new String[] { "choice", "cmd_to_send" }, new int[] { R.id.choice, R.id.cmd_to_send }); listeChoices.setAdapter(adapter_map); listeChoices.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if ((position < listItem.size()) && (position > -1)) { //process selected command HashMap<String, String> map = new HashMap<String, String>(); map = listItem.get(position); cmd_requested = map.get("cmd_to_send"); Tracer.d(mytag, "command selected at Position = " + position + " Commande = " + cmd_requested); new CommandeThread().execute(); } } }); listeChoices.setScrollingCacheEnabled(false); //feature panel 2 which will contain list of selectable choices featurePan2 = new LinearLayout(context); featurePan2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); featurePan2.setGravity(Gravity.CENTER_VERTICAL); featurePan2.setPadding(5, 10, 5, 10); featurePan2.addView(listeChoices); } LL_featurePan.addView(value); handler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 2) { Toast.makeText(getContext(), "Command Failed", Toast.LENGTH_SHORT).show(); } else if (msg.what == 9999) { //Message from cache engine //state_engine send us a signal to notify value changed if (session == null) return; String loc_Value = session.getValue(); Tracer.d(mytag, "Handler receives a new value <" + loc_Value + ">"); value.setText(getStringResourceByName(loc_Value)); //To have the icon colored as it has no state IV_img.setBackgroundResource(Graphics_Manager.Icones_Agent(usage, 2)); } else if (msg.what == 9998) { // state_engine send us a signal to notify it'll die ! Tracer.d(mytag, "cache engine disappeared ===> Harakiri !"); session = null; realtime = false; removeView(LL_background); myself.setVisibility(GONE); if (container != null) { container.removeView(myself); container.recomputeViewAttributes(myself); } try { finalize(); } catch (Throwable t) { } //kill the handler thread itself } } }; //End of handler //================================================================================ /* * New mechanism to be notified by widgetupdate engine when our value is changed * */ WidgetUpdate cache_engine = WidgetUpdate.getInstance(); if (cache_engine != null) { session = new Entity_client(dev_id, state_key, mytag, handler, session_type); if (tracerengine.get_engine().subscribe(session)) { realtime = true; //we're connected to engine //each time our value change, the engine will call handler handler.sendEmptyMessage(9999); //Force to consider current value in session } } //================================================================================ //updateTimer(); //Don't use anymore cyclic refresh.... }
From source file:jahirfiquitiva.iconshowcase.activities.ShowcaseActivity.java
private void showNotLicensedDialog(final Activity act, Preferences mPrefs, final String MARKET_URL) { mPrefs.setFeaturesEnabled(false);// ww w .jav a2 s . c om ISDialogs.showLicenseFailDialog(act, new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(MARKET_URL + act.getPackageName())); act.startActivity(browserIntent); } }, new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) { act.finish(); } }, new MaterialDialog.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { act.finish(); } }, new MaterialDialog.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { act.finish(); } }); }
From source file:org.uguess.android.sysinfo.ProcessManager.java
void endAllExcept(String exception) { Activity ctx = getActivity(); ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); String self = ctx.getPackageName(); ListView lstProcs = getListView(); // skip the dummy info for (int i = 1, size = lstProcs.getCount(); i < size; i++) { ProcessItem rap = (ProcessItem) lstProcs.getItemAtPosition(i); String procName = rap.procInfo.processName; if (!ignoreList.contains(procName) && !self.equals(procName) && !rap.sys && !procName.equals(exception)) { endProcess(am, rap.procInfo.pkgList, self); }/*from w w w . j ava 2 s . c o m*/ } if (!ignoreList.contains(self) && !self.equals(exception)) { Util.killSelf(handler, ctx, am, self); } else { handler.removeCallbacks(task); handler.post(task); } }
From source file:com.just.agentweb.AgentWebUtils.java
@TargetApi(19) static String getFileAbsolutePath(Activity context, Uri fileUri) { if (context == null || fileUri == null) { return null; }/*from ww w . j a v a 2 s. co m*/ LogUtils.i(TAG, "getAuthority:" + fileUri.getAuthority() + " getHost:" + fileUri.getHost() + " getPath:" + fileUri.getPath() + " getScheme:" + fileUri.getScheme() + " query:" + fileUri.getQuery()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, fileUri)) { if (isExternalStorageDocument(fileUri)) { String docId = DocumentsContract.getDocumentId(fileUri); String[] split = docId.split(":"); String type = split[0]; if ("primary".equalsIgnoreCase(type)) { return Environment.getExternalStorageDirectory() + "/" + split[1]; } } else if (isDownloadsDocument(fileUri)) { String id = DocumentsContract.getDocumentId(fileUri); Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); return getDataColumn(context, contentUri, null, null); } else if (isMediaDocument(fileUri)) { String docId = DocumentsContract.getDocumentId(fileUri); String[] split = docId.split(":"); String type = split[0]; Uri contentUri = null; if ("image".equals(type)) { contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; } else if ("video".equals(type)) { contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; } else if ("audio".equals(type)) { contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; } String selection = MediaStore.Images.Media._ID + "=?"; String[] selectionArgs = new String[] { split[1] }; return getDataColumn(context, contentUri, selection, selectionArgs); } else { } } // MediaStore (and general) else if (fileUri.getAuthority().equalsIgnoreCase(context.getPackageName() + ".AgentWebFileProvider")) { String path = fileUri.getPath(); int index = path.lastIndexOf("/"); return getAgentWebFilePath(context) + File.separator + path.substring(index + 1, path.length()); } else if ("content".equalsIgnoreCase(fileUri.getScheme())) { // Return the remote address if (isGooglePhotosUri(fileUri)) { return fileUri.getLastPathSegment(); } return getDataColumn(context, fileUri, null, null); } // File else if ("file".equalsIgnoreCase(fileUri.getScheme())) { return fileUri.getPath(); } return null; }
From source file:org.uguess.android.sysinfo.ProcessManager.java
void handleAction(final ProcessItem rap, int action) { Activity ctx = getActivity(); 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);//ww w. j a v a 2s . co m } } 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:org.uguess.android.sysinfo.ApplicationManager.java
void handleAction(final AppInfoHolder ai, int action) { Activity ctx = getActivity(); String pkgName = ai.appInfo.packageName; switch (action) { case ACTION_MENU: OnClickListener listener = new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss();//from ww w.j a v a 2s . com // 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:org.uguess.android.sysinfo.SiragonManager.java
@Override public boolean onOptionsItemSelected(MenuItem item) { final Activity ctx = getActivity(); if (item.getItemId() == MI_PREFERENCE) { Intent it = new Intent(ctx, InfoSettings.class); it.putExtra(PREF_KEY_SHOW_INFO_ICON, Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_SHOW_INFO_ICON)); it.putExtra(PREF_KEY_SHOW_TASK_ICON, Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_SHOW_TASK_ICON)); it.putExtra(PREF_KEY_AUTO_START_ICON, Util.getBooleanOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_AUTO_START_ICON, false)); it.putExtra(PREF_KEY_DEFAULT_SERVER, Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_SERVER, null)); it.putExtra(PREF_KEY_DEFAULT_EMAIL, Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_EMAIL, null)); it.putExtra(PREF_KEY_DEFAULT_TAB, Util.getIntOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_DEFAULT_TAB, 0)); it.putExtra(PREF_KEY_WIDGET_DISABLED, Util.getStringOption(ctx, PSTORE_SYSINFOMANAGER, PREF_KEY_WIDGET_DISABLED, null)); startActivityForResult(it, 2);//ww w. j a v a 2s. c o m return true; } else if (item.getItemId() == MI_HELP) { Intent it = new Intent(Intent.ACTION_VIEW); String target = "http://www.siragon.com.ve"; //$NON-NLS-1$ ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (info != null && info.isConnected()) { target = "http://www.siragon.com.ve"; //$NON-NLS-1$ } it.setData(Uri.parse(target)); it = Intent.createChooser(it, null); startActivity(it); return true; } ///////////////////////PATH SERVER/////////////////////////////////// else if (item.getItemId() == MI_ABOUT) { ScrollView sv = new ScrollView(ctx); TextView txt = new TextView(ctx); txt.setGravity(Gravity.CENTER_HORIZONTAL); txt.setTextAppearance(ctx, android.R.style.TextAppearance_Medium); sv.addView(txt); String href = "http://www.google.com.ve"; //$NON-NLS-1$ txt.setText(Html.fromHtml(getString(R.string.about_msg, getVersionName(ctx.getPackageManager(), ctx.getPackageName()), href))); txt.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(ctx).setTitle(R.string.app_name).setIcon(R.drawable.logo2).setView(sv) .setNegativeButton(R.string.close, null).create().show(); return true; } else if (item.getItemId() == MI_EXIT) { OnClickListener listener = new OnClickListener() { public void onClick(DialogInterface dialog, int which) { Util.killSelf(handler, ctx, (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE), ctx.getPackageName()); } }; new AlertDialog.Builder(ctx).setTitle(R.string.prompt).setMessage(R.string.exit_prompt) .setPositiveButton(android.R.string.yes, listener).setNegativeButton(android.R.string.no, null) .create().show(); return true; } else if (item.getItemId() == MI_REFRESH) { updateInfo(); return true; } return false; }