List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:net.openid.appauthdemo.Configuration.java
private boolean isRedirectUriRegistered() { // ensure that the redirect URI declared in the configuration is handled by some activity // in the app, by querying the package manager speculatively Intent redirectIntent = new Intent(); redirectIntent.setPackage(mContext.getPackageName()); redirectIntent.setAction(Intent.ACTION_VIEW); redirectIntent.addCategory(Intent.CATEGORY_BROWSABLE); redirectIntent.setData(mRedirectUri); return !mContext.getPackageManager().queryIntentActivities(redirectIntent, 0).isEmpty(); }
From source file:com.google.android.marvin.mytalkback.TtsDiscoveryProxyActivity.java
/** * Queries the engines in {@link #mAvailableEngines} by starting an * {@link Engine#ACTION_CHECK_TTS_DATA} activity for each engine using * {@link #startActivityForResult}.// w w w . jav a2 s. c om * * @return {@code true} if at least one activity was started. */ private boolean queryAvailableEngines() { mExpectedResults = mAvailableEngines.size(); if (mExpectedResults == 0) { return false; } for (int i = 0; i < mAvailableEngines.size(); i++) { final TtsEngineInfo engine = mAvailableEngines.get(i); final Intent checkTtsDataIntent = new Intent(Engine.ACTION_CHECK_TTS_DATA); checkTtsDataIntent.setPackage(engine.name); // Use the engine index as the request code so that we can associate // activity results with their respective engines. final int requestCode = getRequestCodeForIndex(i); startActivityForResult(checkTtsDataIntent, requestCode); } return true; }
From source file:com.fastbootmobile.encore.app.fragments.WelcomeFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // Step specifics if (mStep == 2) { View root = getView();/* w ww .j a v a2 s. c om*/ if (root != null) { root.findViewById(R.id.btnSkip).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); dialog.setTitle(R.string.welcome_skip_dialog_title); dialog.setMessage(R.string.welcome_skip_dialog_body); dialog.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finishWizard(); } }); dialog.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.show(); } }); root.findViewById(R.id.btnBrowse).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ProviderDownloadDialog.newInstance(false).show(getFragmentManager(), "Download"); } }); } } else if (mStep == 3) { // Step 3: Configure plugins ListView lv = (ListView) view.findViewById(R.id.lvProviders); List<ProviderConnection> allProvs = PluginsLookup.getDefault().getAvailableProviders(); final List<ProviderConnection> provs = new ArrayList<>(); for (ProviderConnection prov : allProvs) { if (prov.getConfigurationActivity() != null && !TextUtils.isEmpty(prov.getConfigurationActivity())) { provs.add(prov); } } mStep3Adapter = new ProvidersAdapter(provs); mStep3Adapter.setWhite(true); mStep3Adapter.setWashOutConfigure(true); lv.setAdapter(mStep3Adapter); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ProviderConnection connection = provs.get(position); Intent intent = new Intent(); intent.setPackage(connection.getPackage()); intent.setClassName(connection.getPackage(), connection.getConfigurationActivity()); mConfiguringProvider = connection; try { startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(getActivity(), R.string.toast_retry_plugin_not_ready, Toast.LENGTH_SHORT) .show(); } } }); } }
From source file:com.granita.tasks.notification.NotificationActionIntentService.java
private void resendNotification(NotificationAction notificationAction) { if (ACTION_COMPLETE.equals(notificationAction.getActionType())) { // Due broadcast Intent dueIntent = new Intent(DueAlarmBroadcastHandler.BROADCAST_DUE_ALARM); dueIntent.setPackage(getApplicationContext().getPackageName()); dueIntent.putExtra(DueAlarmBroadcastHandler.EXTRA_TASK_DUE_TIME, notificationAction.getWhen()); dueIntent.putExtra(DueAlarmBroadcastHandler.EXTRA_SILENT_NOTIFICATION, true); sendBroadcast(dueIntent);//from ww w. jav a2s . c om // Start broadcast Intent startIntent = new Intent(StartAlarmBroadcastHandler.BROADCAST_START_ALARM); startIntent.setPackage(getApplicationContext().getPackageName()); startIntent.putExtra(StartAlarmBroadcastHandler.EXTRA_TASK_START_TIME, notificationAction.getWhen()); startIntent.putExtra(StartAlarmBroadcastHandler.EXTRA_SILENT_NOTIFICATION, true); sendBroadcast(startIntent); } }
From source file:com.google.android.marvin.talkback.TtsDiscoveryProxyActivity.java
/** * Queries the engines in {@link #mAvailableEngines} by starting an * {@link Engine#ACTION_CHECK_TTS_DATA} activity for each engine using * {@link #startActivityForResult}.//from w w w. ja v a 2 s. co m * * @return {@code true} if at least one activity was started. */ private boolean queryAvailableEngines() { mExpectedResults = mAvailableEngines.size(); final PackageManager pm = getPackageManager(); for (int i = 0; i < mAvailableEngines.size(); i++) { final TtsEngineInfo engine = mAvailableEngines.get(i); final Intent checkTtsDataIntent = new Intent(Engine.ACTION_CHECK_TTS_DATA); checkTtsDataIntent.setPackage(engine.name); // Use the engine index as the request code so that we can associate // activity results with their respective engines. final int requestCode = getRequestCodeForIndex(i); if (pm.resolveActivity(checkTtsDataIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) { startActivityForResult(checkTtsDataIntent, requestCode); } else { mExpectedResults--; } } return mExpectedResults > 0; }
From source file:com.securecomcode.text.service.KeyCachingService.java
private void handleClearKey() { this.masterSecret = null; stopForeground(true);/*from ww w .ja v a2 s. c o m*/ Intent intent = new Intent(CLEAR_KEY_EVENT); intent.setPackage(getApplicationContext().getPackageName()); sendBroadcast(intent, KEY_PERMISSION); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { MessageNotifier.updateNotification(KeyCachingService.this, null); return null; } }.execute(); }
From source file:com.cloudstudio.BarcodeScanner.java
/** * Initiates a barcode encode./*from w ww .j a v a 2 s . c om*/ * * @param type Endoiding type. * @param data The data to encode in the bar code. */ public void encode(String type, String data) { Intent intentEncode = new Intent(ENCODE_INTENT); intentEncode.putExtra(ENCODE_TYPE, type); intentEncode.putExtra(ENCODE_DATA, data); // avoid calling other phonegap apps intentEncode.setPackage(this.cordova.getActivity().getApplicationContext().getPackageName()); this.cordova.getActivity().startActivity(intentEncode); }
From source file:de.uni_weimar.m18.anatomiederstadt.element.LocationFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_location, container, false); ImageView staticMapView = (ImageView) view.findViewById(R.id.staticMapView); Uri staticMapUri = Uri.parse("https://maps.googleapis.com/maps/api/staticmap").buildUpon() .appendQueryParameter("center", mLatitude + "," + mLongitude).appendQueryParameter("zoom", "17") .appendQueryParameter("size", "400x250") .appendQueryParameter("markers", "color:black|" + mLatitude + "," + mLongitude).build(); Picasso.with(getActivity()).load(staticMapUri.toString()).into(staticMapView); staticMapView.setOnClickListener(new View.OnClickListener() { @Override// ww w .j av a2 s .com public void onClick(View v) { Uri gmmIntentUri = Uri.parse( "geo:" + mLatitude + "," + mLongitude + "?q=" + mLatitude + "," + mLongitude + "(Ziel)"); Log.v(LOG_TAG, "Requested location intent: " + gmmIntentUri.toString()); Intent intent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); intent.setPackage("com.google.android.apps.maps"); startActivity(intent); } }); mInfoText = (TextView) view.findViewById(R.id.locationInfoText); mInfoText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mCheatCounter++; if (mCheatCounter >= 8) { mListener.inProximityAction(mTargetId); } } }); final LocationListener locationListener = this; Button updateButton = (Button) view.findViewById(R.id.updateLocationButton); updateButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mInfoText != null) { mInfoText.setText("..."); mInfoText.setVisibility(View.VISIBLE); } // Request location update LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, locationListener); } }); return view; }
From source file:com.designrifts.ultimatethemeui.fragments.FragmentTheme.java
private void applyNovaTheme() { WallpaperManager setDefaultWallpaper = WallpaperManager.getInstance(getActivity().getApplicationContext()); try {// w w w.j av a 2 s.co m Intent novalauncherIntent = new Intent(ACTION_APPLY_ICON_THEME); novalauncherIntent.setPackage(NOVA_PACKAGE); novalauncherIntent.putExtra(EXTRA_ICON_THEME_TYPE, "GO"); novalauncherIntent.putExtra(EXTRA_ICON_THEME_PACKAGE, getActivity().getPackageName()); startActivity(novalauncherIntent); setDefaultWallpaper.setResource(R.drawable.wallpaper_default); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //finish(); }
From source file:com.gamethrive.TrackGooglePurchase.java
void trackIAP() { if (mServiceConn == null) { mServiceConn = new ServiceConnection() { @Override//from ww w . ja v a 2s . c o m public void onServiceDisconnected(ComponentName name) { iapEnabled = -99; mIInAppBillingService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { try { Class<?> stubClass = Class.forName("com.android.vending.billing.IInAppBillingService$Stub"); Method asInterfaceMethod = stubClass.getMethod("asInterface", android.os.IBinder.class); mIInAppBillingService = asInterfaceMethod.invoke(null, service); QueryBoughtItems(); } catch (Throwable t) { t.printStackTrace(); } } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); appContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else if (mIInAppBillingService != null) QueryBoughtItems(); }