List of usage examples for android.content Intent setPackage
public @NonNull Intent setPackage(@Nullable String packageName)
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private boolean donateViaWeChat() { File qrCode = getQrCode();//from w ww .j a va 2 s. c om if (qrCode == null) { return false; } try { FileUtils.dumpFile(getAssets().open("wechat.png"), qrCode); } catch (IOException e) { UILog.d("cannot dump wechat", e); return false; } refreshQrCode(qrCode); showDonateDialog(); Intent intent = new Intent("com.tencent.mm.action.BIZSHORTCUT"); intent.setPackage("com.tencent.mm"); intent.putExtra("LauncherUI.From.Scaner.Shortcut", true); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); try { startActivity(intent); for (int i = 0; i < 0x3; ++i) { Toast.makeText(this, R.string.select_qr_code, Toast.LENGTH_LONG).show(); } } catch (Throwable t) { // NOSONAR hideDonateDialog(); } return true; }
From source file:my.madet.uniteninfo.OpenVPN.java
/****** start of oncreate **/ @Override//from ww w .j a v a2s. c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_openvpn, container, false); // init progress dialog progressDialog = new ProgressDialog(rootView.getContext()); // init sharedpref sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); dbHandler = new DatabaseHandler(rootView.getContext()); studentEmail = dbHandler.getBiodata().get(DatabaseHandler.BIODATA_KEY_EMAIL); // show linked button linkAccountTextView = (TextView) rootView.findViewById(R.id.txtLabel2); linkAccountUserNameEditText = (EditText) rootView.findViewById(R.id.edittextUserName); linkAccountPasswordEditText = (EditText) rootView.findViewById(R.id.edittextPassword); linkAccountConnectButton = (Button) rootView.findViewById(R.id.buttonConnectToMyVpn); // subscribe and manage subcription button manageSubscriptionButton = (Button) rootView.findViewById(R.id.buttonManageSubs); subscribeButton = (Button) rootView.findViewById(R.id.buttonSubscribe); // generate developerPayload identifier if (sharedPref.getString("devPayloadId", "").equals("")) { // set the payload String data = studentEmail; SharedPreferences.Editor editor = sharedPref.edit(); editor.putString("devPayloadId", data); editor.commit(); } Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); rootView.getContext().bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); subscribeButton.setOnClickListener(new SubscribeButtonClicked(rootView.getContext())); manageSubscriptionButton.setOnClickListener(new ManageSubscriptionButtonClicked(rootView.getContext())); return rootView; }
From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java
private void initializeActionButtons() { RequestParams reqParams = new RequestParams(); reqParams.put("licencia", configuration.getLicense()); reqParams.put("movil", configuration.getMobile()); reqParams.put("viajeID", serv.getIdServicio()); AccionesRestModel salidaServ = new AccionesRestModel("Salida del servicio", "Seguro que desea dar salida al servicio?", "Salida de servicio cancelada", configuration.getUrl() + "/actions/setSalidaMovil", "Dando salida al servicio..."); AccionesRestModel llegadaServ = new AccionesRestModel("Llegada del servicio", "Seguro que desea dar llegada al servicio?", "Llegada de servicio cancelada", configuration.getUrl() + "/actions/setLlegadaMovil", "Dando llegada al servicio..."); doActionServicio(salidaServ, btnSalidaServicio, reqParams); doActionServicio(llegadaServ, btnLlegadaServicio, reqParams); btnFinalServicio.setOnClickListener(new View.OnClickListener() { @Override// w ww.j a v a 2 s . c o m public void onClick(View view) { doStartActivityForResult(FinalServicioActivity.class, 1); } }); btnAttachImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dispatchTakePictureIntent(false); } }); btnHistoriaClinica.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(getActivity(), HistoriaClinicaActivity.class); i.putExtra("viajeId", serv.getIdServicio()); startActivity(i); } }); if (configuration.enabledServiceCancelation()) { btnCancelarServicio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { doStartActivityForResult(CancelarServicioActivity.class, 2); } }); } else { btnCancelarServicio.setVisibility(View.GONE); } btnDistanciaServicio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { String whereToGo = String.format("google.navigation:q=%s,%s&mode=d", serv.getLatitud(), serv.getLongitud()); Uri gmmIntentUri = Uri.parse(whereToGo); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) { startActivity(mapIntent); } else { showToast("Debe instalar Google Maps en su telfono para utilizar este servicio."); } } catch (Exception ex) { showToast("No se pudo iniciar el servicio de distancia de servicio."); } } }); }
From source file:com.matthewmitchell.peercoin_android_wallet.WalletApplication.java
public void replaceWallet(final Wallet newWallet) { internalResetBlockchain(); // implicitly stops blockchain service wallet.shutdownAutosaveAndWait();/* w w w . j a va 2s. c o m*/ wallet = newWallet; config.maybeIncrementBestChainHeightEver(newWallet.getLastBlockSeenHeight()); afterLoadWallet(); final Intent broadcast = new Intent(ACTION_WALLET_CHANGED); broadcast.setPackage(getPackageName()); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); config.disarmBackupReminder(); }
From source file:aerizostudios.com.cropshop.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); fragmentManager = getSupportFragmentManager(); initMenuFragment();// w ww. j a va 2s . c o m toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); toolbarText = (TextView) findViewById(R.id.toolbarText); //shared pref if (isFirstTime()) { prefs = getSharedPreferences(prefName, MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putInt("res", 300); editor.commit(); } prefs = getSharedPreferences(prefName, MODE_PRIVATE); quality = prefs.getInt("res", 300); Typeface billabong = Typeface.createFromAsset(getAssets(), "fonts/Billabong.ttf"); toolbarText.setTypeface(billabong); cropButton = (FancyButton) findViewById(R.id.OpenPhotoButton); followButton = (FancyButton) findViewById(R.id.FollowButton); followButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Uri uri = Uri.parse("http://instagram.com/_u/crop__shop"); Intent likeIng = new Intent(Intent.ACTION_VIEW, uri); likeIng.setPackage("com.instagram.android"); try { startActivity(likeIng); } catch (ActivityNotFoundException e) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/crop__shop"))); } } }); cropButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivityForResult(GetImageFromGallery.getPickImageIntent(MainActivity.this), REQUEST_PICTURE); } }); mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout); mLayout.setTouchEnabled(true); mLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { if (mLayout != null) { if (mLayout.getAnchorPoint() == 1.0f) { mLayout.setAnchorPoint(0.7f); mLayout.setPanelState(SlidingUpPanelLayout.PanelState.ANCHORED); } else { mLayout.setAnchorPoint(1.0f); mLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); } } } @Override public void onPanelExpanded(View panel) { getSupportActionBar().hide(); } @Override public void onPanelCollapsed(View panel) { getSupportActionBar().show(); } @Override public void onPanelAnchored(View panel) { getSupportActionBar().show(); } @Override public void onPanelHidden(View panel) { } }); final ListView friends = (ListView) findViewById(R.id.flipAbout); FlipSettings settings = new FlipSettings.Builder().defaultPage(1).build(); friends.setAdapter(new FriendsAdapter(this, Utils.friends, settings)); }
From source file:com.example.yuen.e_carei.ShowAppointmentList.java
private void open(ApplicationInfo item) { // open app/* w w w . j a va 2 s . c om*/ Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveIntent.setPackage(item.packageName); List<ResolveInfo> resolveInfoList = getPackageManager().queryIntentActivities(resolveIntent, 0); if (resolveInfoList != null && resolveInfoList.size() > 0) { ResolveInfo resolveInfo = resolveInfoList.get(0); String activityPackageName = resolveInfo.activityInfo.packageName; String className = resolveInfo.activityInfo.name; Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); ComponentName componentName = new ComponentName(activityPackageName, className); intent.setComponent(componentName); startActivity(intent); } }
From source file:nuclei.ui.share.PackageTargetManager.java
/** * Create an intent with package specific modifications * * @param authority The file authority provider to be used for sharing files * @param permissionRequestCode Some packages may require we put files on external storage, * this is the permission request code that will be used to request that permission */// w w w. j ava 2 s . c o m public Intent onCreateIntent(Activity activity, String authority, ResolveInfo info, int permissionRequestCode) { int maxLen = getMaxLen(info.activityInfo.packageName); String text = mText; if (maxLen != Integer.MAX_VALUE) text = trim(text, mUrl, maxLen); else if (mText != null && mUrl != null) text += '\n' + mUrl; Intent intent = new Intent( TextUtils.isEmpty(mEmail) && TextUtils.isEmpty(mSms) ? Intent.ACTION_SEND : Intent.ACTION_SENDTO); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setPackage(info.activityInfo.packageName); onSetDefault(activity, info.activityInfo.packageName, authority, intent, text); switch (info.activityInfo.packageName) { case FACEBOOK: intent = onFacebook(activity, intent); break; case WECHAT: intent = onExternalStorage(activity, info.activityInfo.packageName, authority, intent, permissionRequestCode, true); break; case LINE: case TELEGRAM: case WHATSAP: intent = onExternalStorage(activity, info.activityInfo.packageName, authority, intent, permissionRequestCode, false); break; case INSTAGRAM: if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) intent = onExternalStorage(activity, info.activityInfo.packageName, authority, intent, permissionRequestCode, false); break; } return intent; }
From source file:com.ibm.mf.geofence.MFGeofencingManager.java
/** * Query the geofences from the server, based on the current last sync date. *//*w ww . j av a 2 s . c o m*/ private void loadGeofencesFromServer(long lastSyncTimestamp) { HttpRequestCallback<JSONObject> cb = new HttpRequestCallback<JSONObject>() { @Override public void onSuccess(JSONObject result) { try { GeofenceList list = GeofencingJSONUtils.parseGeofences(result); List<PersistentGeofence> geofences = list.getGeofences(); if (!geofences.isEmpty()) { PersistentGeofence.saveInTx(geofences); setInitialLocation(); } if (!geofences.isEmpty() || !list.getDeletedGeofenceCodes().isEmpty()) { Intent broadcastIntent = new Intent(MFGeofenceEvent.ACTION_GEOFENCE_EVENT); broadcastIntent.setPackage(mContext.getPackageName()); MFGeofenceEvent.toIntent(broadcastIntent, MFGeofenceEvent.Type.SERVER_SYNC, geofences, list.getDeletedGeofenceCodes()); mContext.sendBroadcast(broadcastIntent); } log.debug("loadGeofences() got " + list.getGeofences().size() + " geofences"); } catch (Exception e) { HttpRequestError error = new HttpRequestError(-1, e, "error while parsing JSON"); log.debug(error.toString()); } } @Override public void onError(HttpRequestError error) { log.debug(error.toString()); } }; JSONPayloadRequest request = new JSONPayloadRequest(cb, HttpMethod.GET, null); request.setPath(String.format("%s", CONFIG_CONNECTOR_PATH)); if (lastSyncTimestamp >= 0L) { request.addParameter("updatedAfter", Long.toString(lastSyncTimestamp)); } mHttpService.executeRequest(request); }
From source file:net.openid.appauth.AuthorizationService.java
/** * Sends an authorization request to the authorization service, using a * [custom tab](https://developer.chrome.com/multidevice/android/customtabs). * The parameters of this request are determined by both the authorization service * configuration and the provided {@link AuthorizationRequest request object}. Upon completion * of this request, the provided {@link PendingIntent completion PendingIntent} will be invoked. * If the user cancels the authorization request, the provided * {@link PendingIntent cancel PendingIntent} will be invoked. * * @param customTabsIntent/*from www.ja va 2 s . c o m*/ * The intent that will be used to start the custom tab. It is recommended that this intent * be created with the help of {@link #createCustomTabsIntentBuilder(Uri[])}, which will * ensure that a warmed-up version of the browser will be used, minimizing latency. * * @throws android.content.ActivityNotFoundException if no suitable browser is available to * perform the authorization flow. */ public void performAuthorizationRequest(@NonNull AuthorizationRequest request, @NonNull PendingIntent completedIntent, @Nullable PendingIntent canceledIntent, @NonNull CustomTabsIntent customTabsIntent) { checkNotDisposed(); if (mBrowser == null) { throw new ActivityNotFoundException(); } Uri requestUri = request.toUri(); Intent intent; if (mBrowser.useCustomTab) { intent = customTabsIntent.intent; } else { intent = new Intent(Intent.ACTION_VIEW); } intent.setPackage(mBrowser.packageName); intent.setData(requestUri); Logger.debug("Using %s as browser for auth, custom tab = %s", intent.getPackage(), mBrowser.useCustomTab.toString()); intent.putExtra(CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE, CustomTabsIntent.NO_TITLE); Logger.debug("Initiating authorization request to %s", request.configuration.authorizationEndpoint); mContext.startActivity(AuthorizationManagementActivity.createStartIntent(mContext, request, intent, completedIntent, canceledIntent)); }