List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:com.pk.ubulance.Activity.DisplayDriverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_driver); ButterKnife.bind(this); mContext = this; getSupportActionBar().setDisplayHomeAsUpEnabled(true); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.activity_driver_screen); mDialog = ProgressDialog.show(this, "", "Booking Ubulance, Please wait...", true); // callIntent = new Intent(Intent.ACTION_CALL); GetLocation getLocation = new GetLocation(this); if (getLocation.canGetLocation()) { mStartLatitude = Double.toString(getLocation.getLatitude()); mStartLongitude = Double.toString(getLocation.getLongitude()); mUserAddressTV/*from w w w.j a va 2s. c o m*/ .setText(getLocationName(mContext, getLocation.getLatitude(), getLocation.getLongitude())); mShowUserLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String strUri = "http://maps.google.com/maps?q=loc:" + getLocation.getLatitude() + "," + getLocation.getLongitude() + " (" + "You are here" + ")"; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); } }); } else { getLocation.showSettingsAlert(); } Intent intent = this.getIntent(); Double mEndLatitude = intent.getDoubleExtra("mEndLatitude", 0.0); Double mEndLongitude = intent.getDoubleExtra("mEndLongitude", 0.0); mHospitalAddressTV.setText(intent.getStringExtra("vicinity")); mShowHospitalLocation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String strUri = "http://maps.google.com/maps?q=" + mHospitalAddressTV.getText().toString() + " (" + "Hospital" + ")"; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(strUri)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); } }); if (mEndLatitude != 0.0 || mEndLongitude != 0.0) { this.mEndLatitude = Double.toString(mEndLatitude); this.mEndLongitude = Double.toString(mEndLongitude); } if (isNetworkAvailable()) { UberAPI uberAPI = new UberAPI(); mWorkOnProcess = true; try { uberAPI.callUbulance(this, mStartLatitude, mStartLongitude, this.mEndLatitude, this.mEndLongitude, new ServerCallBack() { @Override public void onSuccess(Object result) throws JSONException { final JSONObject finalResult = (JSONObject) result; String product_id = finalResult.getString("product_id"); Log.d("Ubulance", "[FINAL] Product Id: " + product_id); String request_id = finalResult.getString("request_id"); Log.d("Ubulance", "[FINAL] Product Id: " + request_id); mStatusTV.setText("Status: " + finalResult.getString("status")); final JSONObject pickup = finalResult.getJSONObject("pickup"); mEtaTV.setText("ETA: " + pickup.getString("eta") + "min"); final JSONObject driver = finalResult.getJSONObject("driver"); mDriverNameTV.setText("Driver: " + driver.getString("name")); mDriverPhoneTV.setVisibility(View.VISIBLE); mDriverPhoneTV.setText("Call: " + driver.getString("phone_number")); mCallDriver.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_CALL); try { intent.setData(Uri.parse("tel:" + driver.getString("phone_number"))); } catch (JSONException e) { e.printStackTrace(); } if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } startActivity(intent); } }); mDriverRatingTV.setText("Rating: " + driver.getString("rating")); final JSONObject vehicle = finalResult.getJSONObject("vehicle"); displayDriverImage(mContext, driver.getString("picture_url")); mToggleIV.setOnClickListener(new View.OnClickListener() { Boolean toggle = true; @Override public void onClick(View view) { try { if (toggle) { Glide.with(mContext).load(vehicle.getString("picture_url")) .into(mToggleIV); toggle = false; } else { displayDriverImage(mContext, driver.getString("picture_url")); toggle = true; } } catch (JSONException e) { e.printStackTrace(); } } }); mVehicleMakeTV.setText("Make: " + vehicle.getString("make")); mVehicleModelTV.setText("Model: " + vehicle.getString("model")); mVehiclePlateTV.setText("Licence Plate: " + vehicle.getString("license_plate")); mWorkOnProcess = false; mDialog.dismiss(); } @Override public void onFailure(Boolean bool) { mWorkOnProcess = false; } }); } catch (JSONException e) { e.printStackTrace(); } } else { Snackbar.make(mCoordinatorLayout, "No Internet. Please dial 911, if its emergency or try again later", Snackbar.LENGTH_LONG).show(); } }
From source file:org.elasticdroid.LoginView.java
/** * Convenience method to start the userpicker. *///from ww w . j ava 2 s . c om private void startUserPicker() { Intent userPickerIntent = new Intent(); userPickerIntent.setClassName("org.elasticdroid", "org.elasticdroid.UserPickerView"); startActivityForResult(userPickerIntent, PICK_USERS); }
From source file:jp.co.ipublishing.esnavi.activities.ShelterDetailActivity.java
/** * ?//from ww w . j a v a 2 s . c o m */ private void startNavigation(@Nullable final Shelter shelter) { if (shelter == null) { // TODO: ????? return; } // TODO: ???? final Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.driveabout.app.NavigationActivity"); final Uri uri = Uri.parse(String.format("google.navigation:///?ll=%f,%f&q=%s&mode=w", shelter.getCoordinates().latitude, shelter.getCoordinates().longitude, shelter.getName())); intent.setData(uri); startActivity(intent); }
From source file:org.jsharkey.grouphome.LauncherActivity.java
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (!(v.getTag() instanceof EntryInfo)) return;//ww w . ja va2 s. c o m EntryInfo info = (EntryInfo) v.getTag(); final String packageName = info.resolveInfo.activityInfo.applicationInfo.packageName; menu.setHeaderTitle(info.title); Intent detailsIntent = new Intent(); detailsIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); detailsIntent.putExtra("com.android.settings.ApplicationPkgName", packageName); menu.add("App details").setIntent(detailsIntent); Intent deleteIntent = new Intent(Intent.ACTION_DELETE); deleteIntent.setData(Uri.parse("package:" + packageName)); menu.add("Uninstall").setIntent(deleteIntent); }
From source file:com.android.cts.verifier.managedprovisioning.NfcTestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.byod_nfc_test_activity); mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName()); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); mUserMangaer = (UserManager) getSystemService(Context.USER_SERVICE); mDisallowByPolicy = getIntent().getBooleanExtra(EXTRA_DISALLOW_BY_POLICY, false); if (mDisallowByPolicy) { mDevicePolicyManager.addUserRestriction(mAdminReceiverComponent, UserManager.DISALLOW_OUTGOING_BEAM); }/* w ww. jav a 2 s .c o m*/ final Uri uri = createUriForImage(SAMPLE_IMAGE_FILENAME, SAMPLE_IMAGE_CONTENT); Uri[] uris = new Uri[] { uri }; mNfcAdapter = NfcAdapter.getDefaultAdapter(this); mNfcAdapter.setBeamPushUris(uris, this); findViewById(R.id.manual_beam_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { mNfcAdapter.invokeBeam(NfcTestActivity.this); } }); findViewById(R.id.intent_share_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpg"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Specify the package name of NfcBeamActivity so that the tester don't need to // select the activity manually. shareIntent.setClassName(NFC_BEAM_PACKAGE, NFC_BEAM_ACTIVITY); try { startActivity(shareIntent); } catch (ActivityNotFoundException e) { Toast.makeText(NfcTestActivity.this, R.string.provisioning_byod_cannot_resolve_beam_activity, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Nfc beam activity not found", e); } } }); }
From source file:RhodesService.java
public static void runApplication(String appName, Object params) { try {/*from w ww. j a va 2 s . c o m*/ Context ctx = RhodesService.getContext(); PackageManager mgr = ctx.getPackageManager(); PackageInfo info = mgr.getPackageInfo(appName, PackageManager.GET_ACTIVITIES); if (info.activities.length == 0) { Logger.E(TAG, "No activities found for application " + appName); return; } ActivityInfo ainfo = info.activities[0]; String className = ainfo.name; if (className.startsWith(".")) className = ainfo.packageName + className; Intent intent = new Intent(); intent.setClassName(appName, className); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (params != null) { Bundle startParams = new Bundle(); if (params instanceof String) { if (((String) params).length() != 0) { String[] paramStrings = ((String) params).split("&"); for (int i = 0; i < paramStrings.length; ++i) { String key = paramStrings[i]; String value = ""; int splitIdx = key.indexOf('='); if (splitIdx != -1) { value = key.substring(splitIdx + 1); key = key.substring(0, splitIdx); } startParams.putString(key, value); } } } else throw new IllegalArgumentException("Unknown type of incoming parameter"); intent.putExtras(startParams); } ctx.startActivity(intent); } catch (Exception e) { Logger.E(TAG, "Can't run application " + appName + ": " + e.getMessage()); } }
From source file:com.enadein.carlogbook.core.CarLogbookMediator.java
public void openUrl(File file) { if (file != null) { Uri uri = Uri.fromFile(file);// w w w.j av a2 s. com // Uri uri = Uri.parse("http://localhost" + file.getPath()); Intent intent = new Intent(Intent.ACTION_VIEW); // intent.setType("html"); // intent.putExtra(Intent.EXTRA_MIME_TYPES, "text/html"); // intent.setData(uri); intent.setData(uri); intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity"); // intent.addCategory(Intent.CATEGORY_BROWSABLE); try { activity.startActivity(intent); } catch (ActivityNotFoundException e) { System.out.println(e); } } else { Toast.makeText(activity, "error", Toast.LENGTH_LONG); } }
From source file:org.jsharkey.grouphome.LauncherActivity.java
public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); Intent homeIntent = new Intent(); homeIntent.setClassName("com.android.launcher", "com.android.launcher.Launcher"); menu.add("Default home").setIcon(R.drawable.ic_menu_home).setIntent(homeIntent); menu.add("Search").setIcon(android.R.drawable.ic_menu_search); force = menu.add("Expand all").setIcon(android.R.drawable.ic_menu_share) .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { ExpandableListView listView = LauncherActivity.this.getExpandableListView(); ExpandableListAdapter adapter = LauncherActivity.this.getExpandableListAdapter(); switch (expandState) { case STATE_UNKNOWN: case STATE_ALL_COLLAP: // when unknown or collapsed, we force all open for (int i = 0; i < adapter.getGroupCount(); i++) listView.expandGroup(i); expandState = STATE_ALL_EXPAND; break; case STATE_ALL_EXPAND: // when expanded, we force all closed for (int i = 0; i < adapter.getGroupCount(); i++) listView.collapseGroup(i); expandState = STATE_ALL_COLLAP; break; }//www. java 2s .com return true; } }); menu.add("Refresh").setIcon(R.drawable.ic_menu_refresh) .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // clear any database mappings and local json cache // TODO: clear local json cache (when implemented) appdb.deleteAllMappings(); setListAdapter(null); new ProcessTask().execute(); return true; } }); Intent settingsIntent = new Intent(android.provider.Settings.ACTION_SETTINGS); settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); menu.add("Settings").setIcon(android.R.drawable.ic_menu_preferences).setIntent(settingsIntent); return true; }
From source file:edu.mit.mobile.android.demomode.DemoMode.java
@Override public void onItemClick(AdapterView<?> adapter, View v, int position, long id) { switch (adapter.getId()) { case R.id.grid: { final Intent launch = new Intent(); final Cursor c = mAdapter.getCursor(); launch.setClassName(c.getString(c.getColumnIndex(LauncherItem.PACKAGE_NAME)), c.getString(c.getColumnIndex(LauncherItem.ACTIVITY_NAME))); launch.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(launch);//w w w. ja v a 2s . c o m } break; case R.id.all_apps: { final ApplicationInfo appInfo = (ApplicationInfo) mAllApps.getAdapter().getItem(position); startActivity(appInfo.intent); } break; } }
From source file:com.whatsoft.contactbook.activity.ProfileActivity.java
@OnClick(R.id.btn_direction) void onClickDirection() { String s = String.format("google.navigation:q=%s", Utils.formatAddress(contact)); Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(s)); i.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(i);/* w w w .j a v a 2 s .c o m*/ }