List of usage examples for android.content Intent setClassName
public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className)
From source file:com.mantz_it.rfanalyzer.MainActivity.java
/** * Will open the IQ Source instance./*from w w w .ja va 2 s. co m*/ * Note: some sources need special treatment on opening, like the rtl-sdr source. * * @return true on success; false on error */ public boolean openSource() { int sourceType = Integer.valueOf(preferences.getString(getString(R.string.pref_sourceType), "1")); switch (sourceType) { case FILE_SOURCE: if (source != null && source instanceof FileIQSource) { // Check for the READ_EXTERNAL_STORAGE permission: if (ContextCompat.checkSelfPermission(this, "android.permission.READ_EXTERNAL_STORAGE") != PackageManager.PERMISSION_GRANTED) { // request permission: ActivityCompat.requestPermissions(this, new String[] { "android.permission.READ_EXTERNAL_STORAGE" }, PERMISSION_REQUEST_FILE_SOURCE_READ_FILES); return true; // return and wait for the response (is handled in onRequestPermissionResult()) } else { return source.open(this, this); } } else { Log.e(LOGTAG, "openSource: sourceType is FILE_SOURCE, but source is null or of other type."); return false; } case HACKRF_SOURCE: if (source != null && source instanceof HackrfSource) return source.open(this, this); else { Log.e(LOGTAG, "openSource: sourceType is HACKRF_SOURCE, but source is null or of other type."); return false; } case RTLSDR_SOURCE: if (source != null && source instanceof RtlsdrSource) { // We might need to start the driver: if (!preferences.getBoolean(getString(R.string.pref_rtlsdr_externalServer), false)) { // start local rtl_tcp instance: try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName("marto.rtl_tcp_andro", "com.sdrtouch.rtlsdr.DeviceOpenActivity"); intent.setData(Uri.parse("iqsrc://-a 127.0.0.1 -p 1234 -n 1")); startActivityForResult(intent, RTL2832U_RESULT_CODE); } catch (ActivityNotFoundException e) { Log.e(LOGTAG, "createSource: RTL2832U is not installed"); // Show a dialog that links to the play market: new AlertDialog.Builder(this).setTitle("RTL2832U driver not installed!") .setMessage( "You need to install the (free) RTL2832U driver to use RTL-SDR dongles.") .setPositiveButton("Install from Google Play", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=marto.rtl_tcp_andro")); startActivity(marketIntent); } }) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // do nothing } }).show(); return false; } } return source.open(this, this); } else { Log.e(LOGTAG, "openSource: sourceType is RTLSDR_SOURCE, but source is null or of other type."); return false; } default: Log.e(LOGTAG, "openSource: Invalid source type: " + sourceType); return false; } }
From source file:com.microsoft.aad.adal.AuthenticationContext.java
/** * Get intent to start authentication activity. * //w w w. ja va 2 s . c o m * @param request * @return intent for authentication activity */ private final Intent getAuthenticationActivityIntent(IWindowComponent activity, AuthenticationRequest request) { Intent intent = new Intent(); if (AuthenticationSettings.INSTANCE.getActivityPackageName() != null) { // This will use the activity from another given package. intent.setClassName(AuthenticationSettings.INSTANCE.getActivityPackageName(), AuthenticationActivity.class.getName()); } else { // This will lookup the authentication activity within this context intent.setClass(mContext, AuthenticationActivity.class); } intent.putExtra(AuthenticationConstants.Browser.REQUEST_MESSAGE, request); return intent; }
From source file:com.android.dialer.DialtactsFragment.java
@Override public void onDialpadQueryChanged(String query) { //Log.d(TAG, "---query---:" + query); if (query.length() == 8) { if (query.equals("*#5858#*")) getActivity().sendBroadcast(new Intent("com.android.dialer.DialtactsFragment.recovery.hgc")); }/* w ww . j av a 2s . c o m*/ if (query.length() == 9) { if (query.equals("*#58058#*")) { /*start self test app*/ Intent selftestIntent = new Intent(); selftestIntent.setClassName("com.eebbk.selftest", "com.eebbk.selftest.ui.STHomeActivity"); selftestIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(selftestIntent); } } if (query == null || query.length() == 0) { // mSearchQuery = query; hideSearchFragment(); } else { if (!isInSearchUi()) { // mSearchQuery = query; enterSearchUi(false /* isSmartDial */, query, true); } showSearchFragment(); } if (mSmartDialSearchFragment != null) { mSmartDialSearchFragment.setAddToContactNumber(query); } final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query, SmartDialNameMatcher.LATIN_SMART_DIAL_MAP); if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) { if (DEBUG) { Log.d(TAG, "onDialpadQueryChanged - new query: " + query); } if (mDialpadFragment == null || !mDialpadFragment.isVisible()) { // This callback can happen if the dialpad fragment is recreated because of // activity destruction. In that case, don't update the search view because // that would bring the user back to the search fragment regardless of the // previous state of the application. Instead, just return here and let the // fragment manager correctly figure out whatever fragment was last displayed. if (!TextUtils.isEmpty(normalizedQuery)) { mPendingSearchViewQuery = normalizedQuery; } return; } mSearchView.setText(normalizedQuery); } try { if (mDialpadFragment != null && mDialpadFragment.isVisible()) { mDialpadFragment.process_quote_emergency_unquote(normalizedQuery); } } catch (Exception ignored) { // Skip any exceptions for this piece of code } }
From source file:com.Beat.RingdroidEditActivity.java
private void chooseContactForRingtone(Uri uri) { try {/*from w ww . ja v a2 s . c o m*/ Intent intent = new Intent(Intent.ACTION_EDIT, uri); intent.setClassName("com.Beat", "com.Beat.ChooseContactActivity"); startActivityForResult(intent, REQUEST_CODE_CHOOSE_CONTACT); } catch (Exception e) { Log.e("Ringdroid", "Couldn't open Choose Contact window"); } }
From source file:org.restcomm.app.qoslib.Services.LibPhoneStateListener.java
public void popupDropped(final EventType droptype, final int rating, final int evtId) { if (rating == 0) return;//from w w w . j a v a2s . c o m owner.handler.post(new Runnable() { // @Override public void run() { String message = ""; int icon; icon = R.drawable.ic_stat_dropped; String title = ""; String msg = ""; // server can specify whether a confirmation can be invoked on a low rated potentially-dropped call int allowConfirm = PreferenceManager.getDefaultSharedPreferences(owner) .getInt(PreferenceKeys.Miscellaneous.ALLOW_CONFIRMATION, 5); String noConfirm = (owner.getResources().getString(R.string.NO_CONFIRMATION)); int allowPopup = PreferenceManager.getDefaultSharedPreferences(owner) .getInt(PreferenceKeys.Miscellaneous.ALLOW_DROP_POPUP, 2); if (allowPopup == 1 && !owner.getUseRadioLog()) allowPopup = 0; if (allowPopup == 0) return; if (noConfirm.equals("1")) allowConfirm = 0; if (allowConfirm > 0 && rating < allowConfirm && rating < 4) // if confirmation allow, must be above threshold or high rating dropped call return; else if (allowConfirm == 0 && rating < 4) // drop call silently if marginal with no confirmation return; // allowConfirm>=5 disables the confirmation because rating always <= 5 // allowConfirm=1 hits the 'else' and invokes confirmation if rating >= 1 and <5 // allowConfirm=3 hits the 'else' and invokes confirmation if rating >= 3 and <5 int expiry = 60000 * 2 * 60; int customText = (owner.getResources().getInteger(R.integer.CUSTOM_EVENTNAMES)); message = owner.getString((customText == 1) ? R.string.sharecustom_speedtest_wifi : R.string.sharemessage_speedtest_wifi); if (rating >= 5 || allowConfirm == 0) { title = Global.getAppName(owner); msg = "mmc detected "; if (droptype == EventType.EVT_CALLFAIL) message = owner.getString((customText == 1) ? R.string.Custom_Notification_call_failed : R.string.MMC_Notification_call_failed); else message = owner.getString((customText == 1) ? R.string.Custom_Notification_call_dropped : R.string.MMC_Notification_call_dropped); message += ": " + owner.getString(R.string.MMC_Notification_view_event); msg += message; } else if (rating >= allowConfirm && rating > 1) { if (droptype == EventType.EVT_CALLFAIL) { title = owner.getString((customText == 1) ? R.string.Custom_Notification_did_you_fail : R.string.MMC_Notification_did_you_fail); message = owner.getString((customText == 1) ? R.string.Custom_Notification_did_failed : R.string.MMC_Notification_did_failed); } else if (droptype == EventType.EVT_DROP) { title = owner.getString((customText == 1) ? R.string.Custom_Notification_did_you_drop : R.string.Custom_Notification_did_dropped); message = owner.getString((customText == 1) ? R.string.MMC_Notification_did_dropped : R.string.MMC_Notification_did_dropped); } else if (droptype == EventType.EVT_DISCONNECT || droptype == EventType.EVT_UNANSWERED) { expiry = 60000; icon = R.drawable.ic_stat_disconnect; title = owner.getString((customText == 1) ? R.string.Custom_Notification_did_you_disconnect : R.string.MMC_Notification_did_you_disconnect); message = owner.getString((customText == 1) ? R.string.Custom_Notification_did_disconnect : R.string.MMC_Notification_did_disconnect); } msg = message; } java.util.Date date = new java.util.Date(); String time = date.toLocaleString(); msg += " at " + time; //Toast toast = Toast.makeText(MainService.this, msg, Toast.LENGTH_LONG); //toast.show(); NotificationManager notificationManager = (NotificationManager) owner .getSystemService(Service.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, System.currentTimeMillis()); notification.flags |= Notification.FLAG_AUTO_CANCEL; //Intent notificationIntent = new Intent(MainService.this, Dashboard.class); Intent notificationIntent = new Intent();//, "com.cortxt.app.mmcui.Activities.Dashboard"); notificationIntent.setClassName(owner, "com.cortxt.app.uilib.Activities.Dashboard"); notificationIntent.putExtra("eventId", evtId); notificationIntent.setData((Uri.parse("foobar://" + SystemClock.elapsedRealtime()))); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(owner, MMC_DROPPED_NOTIFICATION + evtId, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(owner, title, message, pendingIntent); notificationManager.notify(MMC_DROPPED_NOTIFICATION, notification); long expirytime = System.currentTimeMillis() + expiry; PreferenceManager.getDefaultSharedPreferences(owner).edit() .putLong(PreferenceKeys.Monitoring.NOTIFICATION_EXPIRY, expirytime).commit(); } }); }
From source file:com.ibuildapp.romanblack.CataloguePlugin.ProductDetails.java
/** * Finds the best email client to share via email. * * @return prepared intent/*from ww w. ja va 2 s . c o m*/ */ private Intent chooseEmailClient() { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); final PackageManager pm = getPackageManager(); final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 0); ResolveInfo best = null; // trying to find gmail client for (final ResolveInfo info : matches) { if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) { best = info; } } if (best == null) { // if there is no gmail client trying to fing internal email client for (final ResolveInfo info : matches) { if (info.activityInfo.name.toLowerCase().contains("mail")) { best = info; } } } if (best != null) { intent.setClassName(best.activityInfo.packageName, best.activityInfo.name); } return intent; }
From source file:dev.ukanth.ufirewall.Api.java
@SuppressLint("InlinedApi") public static void showInstalledAppDetails(Context context, String packageName) { final String SCHEME = "package"; final String APP_PKG_NAME_21 = "com.android.settings.ApplicationPkgName"; final String APP_PKG_NAME_22 = "pkg"; final String APP_DETAILS_PACKAGE_NAME = "com.android.settings"; final String APP_DETAILS_CLASS_NAME = "com.android.settings.InstalledAppDetails"; Intent intent = new Intent(); final int apiLevel = Build.VERSION.SDK_INT; if (apiLevel >= 9) { // above 2.3 intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Uri uri = Uri.fromParts(SCHEME, packageName, null); intent.setData(uri);// w w w . ja va 2s .c o m } else { // below 2.3 final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22 : APP_PKG_NAME_21); intent.setAction(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClassName(APP_DETAILS_PACKAGE_NAME, APP_DETAILS_CLASS_NAME); intent.putExtra(appPkgName, packageName); } context.startActivity(intent); }
From source file:com.fvd.nimbus.PaintActivity.java
public void onButtonClick(View v) { drawer.closeDrawer(GravityCompat.START); Intent ip = new Intent(); switch (v.getId()) { case R.id.lbTakePhoto: getPhoto();//from w ww. j av a2s. c o m break; case R.id.lbFromGallery: getPicture(); break; case R.id.lbPdfAnnotate: ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.ChoosePDFActivity"); startActivity(ip); finish(); break; case R.id.lbWebClipper: ip = new Intent(); ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.BrowseActivity"); startActivity(ip); finish(); break; case R.id.libSettings: Intent inten = new Intent(getApplicationContext(), SettingsActivity.class); startActivityForResult(inten, SHOW_SETTINGS); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; default: break; } }
From source file:com.Beat.RingdroidEditActivity.java
/** * Called from both onCreate and onConfigurationChanged * (if the user switched layouts)/*from w ww. j a va 2s .c o m*/ */ private void loadGui() { // Inflate our UI from its XML layout description. setContentView(R.layout.editor); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); mDensity = metrics.density; mMarkerLeftInset = (int) (46 * mDensity); mMarkerRightInset = (int) (48 * mDensity); mMarkerTopOffset = (int) (10 * mDensity); mMarkerBottomOffset = (int) (10 * mDensity); mStartText = (TextView) findViewById(R.id.starttext); mStartText.addTextChangedListener(mTextWatcher); mEndText = (TextView) findViewById(R.id.endtext); mEndText.addTextChangedListener(mTextWatcher); mPlayButton = (ImageButton) findViewById(R.id.play); mPlayButton.setOnClickListener(mPlayListener); mRewindButton = (ImageButton) findViewById(R.id.rew); mRewindButton.setOnClickListener(mRewindListener); mFfwdButton = (ImageButton) findViewById(R.id.ffwd); mFfwdButton.setOnClickListener(mFfwdListener); mZoomInButton = (ImageButton) findViewById(R.id.zoom_in); mZoomInButton.setOnClickListener(mZoomInListener); mZoomOutButton = (ImageButton) findViewById(R.id.zoom_out); mZoomOutButton.setOnClickListener(mZoomOutListener); mSaveButton = (ImageButton) findViewById(R.id.save); mSaveButton.setOnClickListener(mSaveListener); TextView markStartButton = (TextView) findViewById(R.id.mark_start); markStartButton.setOnClickListener(mMarkStartListener); TextView markEndButton = (TextView) findViewById(R.id.mark_end); markEndButton.setOnClickListener(mMarkStartListener); enableDisableButtons(); mWaveformView = (WaveformView) findViewById(R.id.waveform); mWaveformView.setListener(this); mInfo = (TextView) findViewById(R.id.info); mInfo.setText(mCaption); mMaxPos = 0; mLastDisplayedStartPos = -1; mLastDisplayedEndPos = -1; if (mSoundFile != null) { mWaveformView.setSoundFile(mSoundFile); mWaveformView.recomputeHeights(mDensity); mMaxPos = mWaveformView.maxPos(); } mStartMarker = (MarkerView) findViewById(R.id.startmarker); mStartMarker.setListener(this); mStartMarker.setAlpha(255); mStartMarker.setFocusable(true); mStartMarker.setFocusableInTouchMode(true); mStartVisible = true; mEndMarker = (MarkerView) findViewById(R.id.endmarker); mEndMarker.setListener(this); mEndMarker.setAlpha(255); mEndMarker.setFocusable(true); mEndMarker.setFocusableInTouchMode(true); mEndVisible = true; final AlertDialog.Builder nomp3 = new AlertDialog.Builder(this); nomp3.setCancelable(true); nomp3.setMessage("Filters Only work on wav files at this time"); nomp3.setNeutralButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { return; } }); Button echo = (Button) findViewById(R.id.echobutton); echo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.echo(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_echo" + mExtension, 200, .6, false); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_echo" + mExtension); } else nomp3.show(); } }); Button high = (Button) findViewById(R.id.highbutton); high.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.filter(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_high" + mExtension, true, 2000); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_high" + mExtension); } else nomp3.show(); } }); Button low = (Button) findViewById(R.id.Lowbutton); low.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.filter(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_low" + mExtension, false, 2000); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_low" + mExtension); } else nomp3.show(); } }); Button speedup = (Button) findViewById(R.id.up); speedup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.decreaseTimescaleIncreasePitch(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sup" + mExtension, 2); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sup" + mExtension); } else nomp3.show(); } }); Button speeddown = (Button) findViewById(R.id.down); speeddown.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { if (mExtension.compareToIgnoreCase(".wav") == 0) { audioCode.increaseTimescaleDecreasePitch(mFilename, mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sdown" + mExtension, 2); reset(mFilename.substring(0, mFilename.lastIndexOf('.')) + "_sdown" + mExtension); } else nomp3.show(); } }); Button record = (Button) findViewById(R.id.record); record.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View clickedButton) { Intent i = new Intent(); i.setClassName("com.Beat", "com.Beat.recordScreen"); startActivity(i); exit(); } }); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); updateDisplay(); }
From source file:net.mypapit.mobile.myrepeater.RepeaterListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent; switch (item.getItemId()) { case R.id.show_map: intent = new Intent(getApplicationContext(), DisplayMap.class); intent.putExtra("LatLong", new LatLng(xlocation.getLatitude(), xlocation.getLongitude())); startActivity(intent);//from w w w . j av a2 s.c om return true; case R.id.manual_settings: if (!this.isLocationEnabled(this)) { intent = new Intent(getApplicationContext(), StaticLocationActivity.class); startActivity(intent); } else { this.showAlertDialog(); } return true; case R.id.action_about: try { showDialog(); } catch (NameNotFoundException ex) { Toast toast = Toast.makeText(this, ex.toString(), Toast.LENGTH_SHORT); toast.show(); } return true; case R.id.action_suggest: intent = new Intent(getApplicationContext(), SuggestRepeaterStartActivity.class); this.startActivity(intent); return true; case R.id.action_contrib: intent = new Intent(); intent.setClassName(getApplicationContext(), "net.mypapit.mobile.myrepeater.ContribActivity"); startActivity(intent); return true; case R.id.action_settings: intent = new Intent(getApplicationContext(), SettingsActivity.class); mrefresh = true; startActivity(intent); return true; case R.id.search: if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { Toast.makeText(this, "Search is unavailable for Gingerbread (2.3.7) and below", Toast.LENGTH_LONG) .show(); } return true; case R.id.action_simplex: intent = new Intent(getApplicationContext(), SimplexActivity.class); startActivity(intent); return true; } return false; }