List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:fi.iki.murgo.irssinotifier.SettingsActivity.java
private void handleIcb() { CheckBoxPreference showIcbIconPreference = (CheckBoxPreference) findPreference("IcbEnabled"); if (!IntentSniffer.isPackageAvailable(this, IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT)) { PreferenceCategory icbCategory = (PreferenceCategory) findPreference("IcbCategory"); icbCategory.setEnabled(false);// w w w .j av a2 s. c om showIcbIconPreference.setChecked(false); showIcbIconPreference.setSummary("Install Irssi ConnectBot to show it in the action bar"); } else { showIcbIconPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { IrssiNotifierActivity.refreshIsNeeded(); return true; } }); Preference icbHostPref = findPreference("IcbHost"); Preferences prefs = new Preferences(this); String hostName = prefs.getIcbHostName(); String summary = "Select which Irssi ConnectBot host to open when pressing the ICB icon"; if (hostName != null) summary += ". Currently selected host: " + hostName; icbHostPref.setSummary(summary); icbHostPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent i = new Intent("android.intent.action.PICK"); i.setClassName(IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT, IrssiConnectbotLauncher.PACKAGE_IRSSICONNECTBOT + ".HostListActivity"); startActivityForResult(i, ICB_HOST_REQUEST_CODE); return true; } }); } }
From source file:com.saulcintero.moveon.fragments.History.java
public static void sendAction(final Activity act, int[] idList, String[] nameList, String[] activityList, String[] shortDescriptionList, String[] longDescriptionList) { ArrayList<Integer> positions = new ArrayList<Integer>(); for (int p = 0; p < idList.length; p++) { String nameToSearch = osmFilesNameFromUploadPosition.get(p).substring(0, osmFilesNameFromUploadPosition.get(p).length() - 4); positions.add(ArrayUtils.indexOf(listOfFiles, nameToSearch)); }/* w w w. j a va 2 s . c o m*/ for (int j = 0; j < idList.length; j++) { final String name = nameList[j]; final String activity = activityList[j]; final String shortDescription = shortDescriptionList[j]; final String longDescription = longDescriptionList[j]; final String url = osmUrlsToShare.get(positions.get(j)); Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); sendIntent.setType("text/plain"); List<ResolveInfo> activities = act.getPackageManager().queryIntentActivities(sendIntent, 0); AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(act.getText(R.string.send_to) + " " + name + " " + act.getText(R.string.share_with)); final ShareIntentListAdapter adapter = new ShareIntentListAdapter(act, R.layout.social_share, activities.toArray()); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ResolveInfo info = (ResolveInfo) adapter.getItem(which); if (info.activityInfo.packageName.contains("facebook")) { Intent i = new Intent("android.intent.action.PUBLISH_TO_FB_WALL"); i.putExtra("name", activity + " " + name); i.putExtra("msg", String.format("%s", shortDescription)); i.putExtra("link", String.format("%s", url)); act.sendBroadcast(i); } else { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); intent.setType("text/plain"); if ((info.activityInfo.packageName.contains("twitter")) || (info.activityInfo.packageName.contains("sms")) || (info.activityInfo.packageName.contains("mms"))) { intent.putExtra(Intent.EXTRA_TEXT, shortDescription + url); } else { intent.putExtra(Intent.EXTRA_TEXT, longDescription + url); } act.startActivity(intent); } } }); builder.create().show(); } }
From source file:com.gzsll.downloads.DownloadNotification.java
private PendingIntent getPendingContentIntent(NotificationItem item) { Intent intent = new Intent(); intent.setAction(Constants.ACTION_LIST); intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.setClassName(mContext.getPackageName(), DownloadReceiver.class.getName()); intent.setData(ContentUris.withAppendedId(Downloads.ALL_DOWNLOADS_CONTENT_URI, item.mId)); intent.putExtra("multiple", item.mTitleCount > 1); return PendingIntent.getBroadcast(mContext, 0, intent, 0); }
From source file:org.zeroxlab.zeroxbenchmark.Case.java
protected Intent generateIntent() { /* if run out of the repeat times, go back directly */ if (mRepeatNow >= mRepeatMax) { return null; }/* www. j av a 2 s . com*/ Intent intent = new Intent(); intent.setClassName(PACKAGE, TESTER); Case.putRound(intent, mCaseRound); Case.putSource(intent, TAG); Case.putIndex(intent, mRepeatNow); mRepeatNow = mRepeatNow + 1; return intent; }
From source file:fm.smart.r1.CreateExampleActivity.java
public void onClick(View v) { EditText exampleInput = (EditText) findViewById(R.id.create_example_sentence); EditText translationInput = (EditText) findViewById(R.id.create_example_translation); EditText exampleTransliterationInput = (EditText) findViewById(R.id.sentence_transliteration); EditText translationTransliterationInput = (EditText) findViewById(R.id.translation_transliteration); final String example = exampleInput.getText().toString(); final String translation = translationInput.getText().toString(); if (TextUtils.isEmpty(example) || TextUtils.isEmpty(translation)) { Toast t = Toast.makeText(this, "Example and translation are required fields", 150); t.setGravity(Gravity.CENTER, 0, 0); t.show();/*w w w. j a v a 2 s. c o m*/ } else { final String example_language_code = Utils.LANGUAGE_MAP.get(example_language); final String translation_language_code = Utils.LANGUAGE_MAP.get(translation_language); final String example_transliteration = exampleTransliterationInput.getText().toString(); final String translation_transliteration = translationTransliterationInput.getText().toString(); if (LoginActivity.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid // navigation // back to this? LoginActivity.return_to = CreateExampleActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("goal_id", goal_id); LoginActivity.params.put("item_id", item_id); LoginActivity.params.put("example", example); LoginActivity.params.put("translation", translation); LoginActivity.params.put("example_language", example_language); LoginActivity.params.put("translation_language", translation_language); LoginActivity.params.put("example_transliteration", example_transliteration); LoginActivity.params.put("translation_transliteration", translation_transliteration); startActivity(intent); } else { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Example ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_example = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ try { // TODO failures here could derail all ... CreateExampleActivity.add_item_goal_result = new AddItemResult( Main.lookup.addItemToGoal(Main.transport, goal_id, item_id, null)); Result result = null; try { result = Main.lookup.createExample(Main.transport, translation, translation_language_code, translation, null, null, null); JSONObject json = new JSONObject(result.http_response); String text = json.getString("text"); String translation_id = json.getString("id"); result = Main.lookup.createExample(Main.transport, example, example_language_code, example_transliteration, translation_id, item_id, goal_id); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } CreateExampleActivity.create_example_result = new CreateExampleResult(result); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_example.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_example.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_example.start(); } } }
From source file:com.senior.fragments.GoogleFragment.java
@Override public View onCreateView(LayoutInflater inflate, ViewGroup container, Bundle savedInstanceState) { Log.i("Google", "Oncreate view called"); map = inflate.inflate(R.layout.google_fragment, container, false); buildingList = (Spinner) map.findViewById(R.id.buildings); buildingNames.clear();//from ww w . j a v a 2 s .c om buildingCoord.clear(); //Adds and organizes the buildings alphabetically buildingNames.addAll(Arrays.asList(getResources().getStringArray(R.array.listOfBuildings))); Collections.sort(buildingNames, String.CASE_INSENSITIVE_ORDER); buildingCoord.addAll(Arrays.asList(getResources().getStringArray(R.array.listOfBuildings))); Collections.sort(buildingCoord, String.CASE_INSENSITIVE_ORDER); for (int index = 0; index < buildingNames.size(); index++) { buildingNames.set(index, buildingNames.get(index).substring(0, buildingNames.get(index).indexOf(','))); } buildingNames.add(0, "Select one"); ArrayAdapter<String> array = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, buildingNames); buildingList.setAdapter(array); //Places point on building when building is selected buildingList.setOnItemSelectedListener(new OnItemSelectedListener() { private double lat = 0; private double lon = 0; private String latString; private String longString; @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { if (TAMUK != null && arg2 != 0) { navigate = 0; latString = buildingCoord.get(arg2 - 1); latString = latString.substring(latString.indexOf(',') + 1, latString.lastIndexOf(',')); longString = buildingCoord.get(arg2 - 1); longString = longString.substring(longString.lastIndexOf(',') + 1); lat = Double.parseDouble(latString); lon = Double.parseDouble(longString); TAMUK.clear(); TAMUK.addMarker(new MarkerOptions().position(new LatLng(lat, lon)) .title(buildingNames.get(arg2)).snippet("Touch marker twice to start navigation")); TAMUK.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { navigate++; if (navigate == 2) { navigate = 0; String url = "http://maps.google.com/maps?f=d&daddr=" + lat + "," + lon + "&dirflg=d"; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); } return false; } }); TAMUK.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 17)); } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); setUpMap(); return map; }
From source file:com.seo.downloadproviders.downloads.DownloadNotification.java
private void updateActiveNotification(Collection<DownloadInfo> downloads) { // Collate the notifications mNotifications.clear();//from www .j av a2 s .c om for (DownloadInfo download : downloads) { if (!isActiveAndVisible(download)) { continue; } String packageName = download.mPackage; long max = download.mTotalBytes; long progress = download.mCurrentBytes; long id = download.mId; String title = download.mTitle; if (title == null || title.length() == 0) { title = mContext.getResources().getString(R.string.download_unknown_title); } NotificationItem item; if (mNotifications.containsKey(packageName)) { item = mNotifications.get(packageName); item.addItem(title, progress, max); } else { item = new NotificationItem(); item.mId = (int) id; item.mPackageName = packageName; item.mDescription = download.mDescription; item.addItem(title, progress, max); mNotifications.put(packageName, item); } if (download.mStatus == Downloads.STATUS_QUEUED_FOR_WIFI && item.mPausedText == null) { item.mPausedText = mContext.getResources().getString(R.string.notification_need_wifi_for_size); } } // Add the notifications for (NotificationItem item : mNotifications.values()) { // Build the notification object final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); boolean hasPausedText = (item.mPausedText != null); int iconResource = android.R.drawable.stat_sys_download; if (hasPausedText) { iconResource = android.R.drawable.stat_sys_warning; } builder.setSmallIcon(iconResource); builder.setOngoing(true); // set notification "when" to be first time this DownloadInfo.mId // was encountered, which avoids fighting with other notifs. long firstShown = mFirstShown.get(item.mId, -1); if (firstShown == -1) { firstShown = System.currentTimeMillis(); mFirstShown.put(item.mId, firstShown); } builder.setWhen(firstShown); boolean hasContentText = false; StringBuilder title = new StringBuilder(item.mTitles[0]); if (item.mTitleCount > 1) { title.append(mContext.getString(R.string.notification_filename_separator)); title.append(item.mTitles[1]); if (item.mTitleCount > 2) { title.append(mContext.getString(R.string.notification_filename_extras, new Object[] { Integer.valueOf(item.mTitleCount - 2) })); } } else if (!TextUtils.isEmpty(item.mDescription)) { builder.setContentText(item.mDescription); hasContentText = true; } builder.setContentTitle(title); if (hasPausedText) { builder.setContentText(item.mPausedText); } else { builder.setProgress((int) item.mTotalTotal, (int) item.mTotalCurrent, item.mTotalTotal == -1); if (hasContentText) { builder.setContentInfo(buildPercentageLabel(mContext, item.mTotalTotal, item.mTotalCurrent)); } } Intent intent = new Intent(Constants.ACTION_LIST); intent.setClassName(mContext.getPackageName(), DownloadReceiver.class.getName()); intent.setData(ContentUris.withAppendedId(Downloads.ALL_DOWNLOADS_CONTENT_URI, item.mId)); intent.putExtra("multiple", item.mTitleCount > 1); builder.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent, 0)); mNotifManager.notify(item.mId, builder.build()); } }
From source file:com.trellmor.mocklocationpicture.MLPActivity.java
private void startDevelopmentSettings() { Intent intent = new Intent(); intent.setClassName("com.android.settings", "com.android.settings.DevelopmentSettings"); startActivity(intent);// w w w .j a va 2s.c o m }
From source file:net.survivalpad.android.ArticleViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(); int id = item.getItemId(); if (id == R.id.action_update) { intent.setClassName(getPackageName(), getPackageName() + ".ArticleUpdateActivity"); } else if (id == R.id.action_replicate) { intent.setClassName(getPackageName(), getPackageName() + ".ArticleReplicateActivity"); } else if (id == R.id.action_translate) { intent.setClassName(getPackageName(), getPackageName() + ".ArticleTranslateActivity"); }/*from w ww. jav a 2 s . c om*/ intent.putExtra(ArticleEditActivity.KEY_ARTICLE_ID, mArticle.getId()); startActivity(intent); return super.onOptionsItemSelected(item); }
From source file:com.google.android.apps.forscience.whistlepunk.project.experiment.UpdateExperimentFragment.java
private void goToParent() { Intent upIntent; if (mParentComponent != null) { upIntent = new Intent(); upIntent.setClassName(mParentComponent.getPackageName(), mParentComponent.getClassName()); } else {//from w ww. j a v a2 s .c om upIntent = NavUtils.getParentActivityIntent(getActivity()); } upIntent.putExtra(ExperimentDetailsFragment.ARG_EXPERIMENT_ID, mExperimentId); if (getActivity() != null) { NavUtils.navigateUpTo(getActivity(), upIntent); } else { Log.e(TAG, "Can't exit activity because it's no longer there."); } }