List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:org.wso2.app.catalog.api.ApplicationManager.java
/** * Checks whether the DownloadManager is available on the device. * * @param context - Context of the calling activity. *///from w w w.j ava 2s . c o m public boolean isDownloadManagerAvailable(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setClassName(resources.getString(R.string.android_download_manager_ui_resolver), resources.getString(R.string.android_download_manager_list_resolver)); return context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY) .size() > 0; }
From source file:fm.smart.r1.activity.CreateItemActivity.java
public void onClick(View v) { EditText cueInput = (EditText) findViewById(R.id.cue); EditText responseInput = (EditText) findViewById(R.id.response); Spinner posInput = (Spinner) findViewById(R.id.pos); EditText characterResponseInput = (EditText) findViewById(R.id.response_character); EditText characterCueInput = (EditText) findViewById(R.id.cue_character); final String cue = cueInput.getText().toString(); final String response = responseInput.getText().toString(); final String pos = posInput.getSelectedItem().toString(); final String character_cue = characterCueInput.getText().toString(); final String character_response = characterResponseInput.getText().toString(); String pos_code = Utils.POS_MAP.get(pos); if (TextUtils.isEmpty(pos_code)) { pos_code = "NONE"; }/*from ww w . j a va2 s .com*/ final String final_pos_code = pos_code; if (Main.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 = CreateItemActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("list_id", list_id); LoginActivity.params.put("cue", cue); LoginActivity.params.put("response", response); LoginActivity.params.put("cue_language", cue_language); LoginActivity.params.put("response_language", response_language); LoginActivity.params.put("pos", pos); LoginActivity.params.put("character_cue", character_cue); LoginActivity.params.put("character_response", character_response); startActivity(intent); } else { // TODO cue and response languages need to be inferred from list we are // adding to ... Might want to fix those, i.e. not allow variation // on // search ... // TODO wondering whether there is some way to edit existing items // ... final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Item ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_item = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ CreateItemActivity.create_item_result = createItem(cue, cue_language, character_cue, final_pos_code, response, response_language, character_response, list_id); myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_item.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_item.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_item.start(); } }
From source file:com.macleod2486.fragment.Map.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.map, container, false); //Gets the building lists into an arraylist buildingList.clear();//from ww w . ja va 2 s. co m buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.fraternity))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.sorority))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.maincampus))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.intramuralfields))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.pickleresearchcampus))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.parkinggarages))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.residencehalls))); Collections.sort(buildingList, String.CASE_INSENSITIVE_ORDER); completeList.clear(); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.fraternity))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.sorority))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.maincampus))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.pickleresearchcampus))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.parkinggarages))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.residencehalls))); Collections.sort(completeList, String.CASE_INSENSITIVE_ORDER); //Only puts the building name for the autocomplete text for (int index = 0; index < buildingList.size(); index++) { buildingList.set(index, buildingList.get(index).substring(0, buildingList.get(index).indexOf(','))); } search = (AutoCompleteTextView) view.findViewById(R.id.mapSearch); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, buildingList); search.setThreshold(1); search.setAdapter(adapter); search.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { final Double lat; final Double lon; final String selection = (String) parent.getItemAtPosition(position); latitude = completeList.get(buildingList.indexOf(selection)); latitude = latitude.substring(latitude.indexOf(",") + 1, latitude.lastIndexOf(",")); longitude = completeList.get(buildingList.indexOf(selection)); longitude = longitude.substring(longitude.lastIndexOf(",") + 1); lat = Double.parseDouble(latitude); lon = Double.parseDouble(longitude); navigate = 0; final MarkerOptions markerOpt = new MarkerOptions(); markerOpt.position(new LatLng(lat, lon)).title(selection); markerOpt.snippet("Touch marker twice to navigate"); UT.clear(); UT.addMarker(markerOpt); UT.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 17)); UT.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { Log.i("Map", "Marker clicked"); navigate++; //If the marker is clicked twice it launches navigation if (navigate == 2) { navigate = 0; String url = "http://maps.google.com/maps?f=d&daddr=" + latitude + "," + longitude + "&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; } }); imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(search.getWindowToken(), 0); } }); search.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { if (arg0.toString().isEmpty()) { clear.setVisibility(View.INVISIBLE); } } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { Log.i("Map", "Text changed"); clear.setVisibility(View.VISIBLE); } }); clear = (ImageButton) view.findViewById(R.id.clearButton); clear.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { search.setText(""); clear.setVisibility(View.INVISIBLE); } }); //Sets up the map setUpUT(); return view; }
From source file:edu.mit.media.funf.configured.ConfiguredPipeline.java
public void sendProbeRequest(String probeName) { Bundle[] requests = getConfig().getDataRequests().get(probeName); if (requests == null) { requests = new Bundle[] {}; // null is same as blank config }/*from ww w .j a v a 2 s . com*/ ArrayList<Bundle> dataRequest = new ArrayList<Bundle>(Arrays.asList(requests)); Intent request = new Intent(Probe.ACTION_REQUEST); request.setClassName(this, probeName); request.putExtra(Probe.CALLBACK_KEY, getCallback()); request.putExtra(Probe.REQUESTS_KEY, dataRequest); startService(request); }
From source file:fm.smart.r1.activity.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();/*from w w w . j a va2 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 (Main.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("list_id", list_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_list_result = ItemActivity.addItemToList(list_id, item_id, CreateExampleActivity.this); CreateExampleActivity.create_example_result = createExample(example, example_language_code, example_transliteration, translation, translation_language_code, translation_transliteration, item_id, list_id); CreateExampleActivity.add_sentence_list_result = ItemActivity.addSentenceToList( CreateExampleActivity.create_example_result.http_response, item_id, list_id, CreateExampleActivity.this); } 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.flipzu.flipzu.Listings.java
private void goToRecorder() { debug.logD(TAG, "Listings goToRecorder"); Intent recIntent = new Intent(); recIntent.setClassName("com.flipzu.flipzu", "com.flipzu.flipzu.Recorder"); startActivity(recIntent);//from ww w . j av a2 s . co m }
From source file:xiaofei.library.hermes.internal.Channel.java
/** * bind HermesService//w w w . j a v a2 s . co m * @param context * @param packageName * @param service */ public void bind(Context context, String packageName, Class<? extends HermesService> service) { HermesServiceConnection connection; synchronized (this) { if (getBound(service)) { return; } Boolean binding = mBindings.get(service); if (binding != null && binding) { return; } mBindings.put(service, true); connection = new HermesServiceConnection(service); mHermesServiceConnections.put(service, connection); } Intent intent; if (TextUtils.isEmpty(packageName)) { intent = new Intent(context, service); } else { intent = new Intent(); intent.setClassName(packageName, service.getName()); } context.bindService(intent, connection, Context.BIND_AUTO_CREATE); }
From source file:me.xingrz.finder.EntriesActivity.java
protected Intent intentToView(Uri uri, String mime) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, mime);/* ww w . ja va 2s. c o m*/ intent.addCategory(Intent.CATEGORY_DEFAULT); for (ResolveInfo resolved : getPackageManager().queryIntentActivities(intent, 0)) { if (BuildConfig.APPLICATION_ID.equals(resolved.activityInfo.packageName)) { intent.setClassName(this, resolved.activityInfo.name); intent.putExtra(EXTRA_ALLOW_BACK, true); } } return intent; }
From source file:com.flipzu.flipzu.Listings.java
private void logoutListings() { /* track "Logout" */ tracker.trackEvent("Listings", "Click", "Logout", 0); SharedPreferences.Editor editor = settings.edit(); editor.putString("username", null); editor.putString("token", null); editor.commit();//from w w w . j a va 2 s . c o m Intent loginIntent = new Intent(); loginIntent.setClassName("com.flipzu.flipzu", "com.flipzu.flipzu.Flipzu"); startActivity(loginIntent); finish(); }
From source file:org.wahtod.wififixer.ui.MainActivity.java
void authCheck() { if (!PrefUtil.readBoolean(this, this.getString(R.string.isauthed))) { // Handle Donate Auth PackageManager pm = getPackageManager(); String component = getString(R.string.donateservice); Intent intent = new Intent(component); ResolveInfo info = pm.resolveService(intent, 0); if (info != null) { intent.setClassName(info.serviceInfo.packageName, info.serviceInfo.name); this.startService(intent); }//from w w w .j a v a 2 s . c om nagNotification(this); } }