List of usage examples for android.content Intent setClass
public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls)
From source file:com.microsoft.aad.adal.AuthenticationContext.java
/** * Get intent to start authentication activity. * /*www. j a v a 2 s .com*/ * @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.facebook.Session.java
private Intent getLoginActivityIntent(AuthorizationRequest request) { Intent intent = new Intent(); intent.setClass(getStaticContext(), LoginActivity.class); intent.setAction(request.getLoginBehavior().toString()); // Let LoginActivity populate extras appropriately AuthorizationClient.AuthorizationRequest authClientRequest = request.getAuthorizationClientRequest(); Bundle extras = LoginActivity.populateIntentExtras(authClientRequest); intent.putExtras(extras);//from w w w . ja v a2 s .c o m return intent; }
From source file:com.facebook.Session.java
private void validateLoginBehavior(AuthorizationRequest request) { if (request != null && !request.isLegacy) { Intent intent = new Intent(); intent.setClass(getStaticContext(), LoginActivity.class); if (!resolveIntent(intent)) { throw new FacebookException(String.format( "Cannot use SessionLoginBehavior %s when %s is not declared as an activity in AndroidManifest.xml", request.getLoginBehavior(), LoginActivity.class.getName())); }/*from ww w. j av a 2 s .c o m*/ } }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Allows to install a new icon for the application. * * This method need two additional permissions in the application: * * <code>/*from w ww. j a v a2 s. c o m*/ * <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> * </code> * * @param context The application context. * @param appMain The application main class * @param appName The application name * @param appIcon The bitmap of the application icon. Can be null. If null, the * appIconResId must be provided. * @param appIconResId Specify this only if no bitmap is set in the call to this method. */ public static void application_shortcutAdd(Context context, Class appMain, String appName, Bitmap appIcon, int appIconResId, boolean removeCurrent) { // Intent launcher of the application Intent shortcutIntent = new Intent("android.intent.action.MAIN"); shortcutIntent.addCategory("android.intent.category.LAUNCHER"); shortcutIntent.setClass(context, appMain); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //Intent to add the new application icon. // // Decorate the shortcut Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName); if (appIcon != null) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON, appIcon); } else if (appIconResId != 0) { addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context.getApplicationContext(), appIconResId)); } // Inform launcher to create shortcut addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); context.sendBroadcast(addIntent); }
From source file:com.oakesville.mythling.MediaActivity.java
/** * Requires MythTV content.cpp patch to work without storage groups. *//*from ww w. ja v a 2 s . co m*/ private void playRawVideoStream(Item item) throws IOException, JSONException { Uri uri; if (item.isDownloaded()) { uri = getDownload(item); } else { URL baseUrl = getAppSettings().getMythTvServicesBaseUrlWithCredentials(); String fileUrl = baseUrl + "/Content/GetFile?"; if (item.getStorageGroup() == null) fileUrl += "StorageGroup=None&"; else fileUrl += "StorageGroup=" + item.getStorageGroup().getName() + "&"; fileUrl += "FileName=" + URLEncoder.encode(item.getFilePath(), "UTF-8"); uri = Uri.parse(fileUrl); } PlaybackOption playbackOption = getPlaybackOption(item, PlaybackOptions.STREAM_FILE); boolean isExternalPlayer = playbackOption.isAppPlayer(); if (!isExternalPlayer && item.isRecording() && isUseCutList()) { new PlayWithCutListTask(uri, (Recording) item, playbackOption).execute(); } else { stopProgress(); Intent videoIntent = new Intent(Intent.ACTION_VIEW); videoIntent.setDataAndType(uri, "video/*"); if (!isExternalPlayer) { videoIntent.setClass(getApplicationContext(), VideoPlayerActivity.class); videoIntent.putExtra(VideoPlayerActivity.PLAYER, playbackOption.getPlayer()); if (!item.isDownloaded()) { if (item.isLengthKnown()) videoIntent.putExtra(VideoPlayerActivity.ITEM_LENGTH_SECS, item.getLength()); String streamingAuthType = getAppSettings().getMythTvServicesAuthType(); if (streamingAuthType != AuthType.None.toString()) videoIntent.putExtra(VideoPlayerActivity.AUTH_TYPE, streamingAuthType); } } startActivity(videoIntent); } }
From source file:com.oakesville.mythling.MediaActivity.java
protected void playLiveStream(LiveStreamInfo streamInfo, Item item) throws IOException, JSONException { String streamUrl = appSettings.getMythTvServicesBaseUrlWithCredentials() + streamInfo.getRelativeUrl(); // avoid retrieving unnecessary audio-only streams int lastDot = streamUrl.lastIndexOf('.'); streamUrl = streamUrl.substring(0, lastDot) + ".av" + streamUrl.substring(lastDot); stopProgress();//from www .ja v a 2 s. c o m PlaybackOption playbackOption = getPlaybackOption(item, PlaybackOptions.STREAM_HLS); boolean isExternalPlayer = playbackOption.isAppPlayer(); if (!isExternalPlayer && item.isRecording() && isUseCutList()) { new PlayWithCutListTask(Uri.parse(streamUrl), (Recording) item, playbackOption).execute(); } else { Intent videoIntent = new Intent(Intent.ACTION_VIEW); videoIntent.setDataAndType(Uri.parse(streamUrl), "video/*"); if (!playbackOption.isAppPlayer()) { videoIntent.setClass(getApplicationContext(), VideoPlayerActivity.class); videoIntent.putExtra(VideoPlayerActivity.PLAYER, playbackOption.getPlayer()); if (item.isLengthKnown()) videoIntent.putExtra(VideoPlayerActivity.ITEM_LENGTH_SECS, item.getLength()); } startActivity(videoIntent); } }
From source file:com.lewa.crazychapter11.MainActivity.java
private void AddNoification() { nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Button btn_send = (Button) findViewById(R.id.btn_send); Button btn_cancel = (Button) findViewById(R.id.btn_cancel); /*/* w w w . j a va 2 s . c om*/ * btn_send.setOnClickListener(new OnClickListener() { * * @Override public void onClick(View source) { // acionBar.show(); * EditText show_txt=(EditText)findViewById(R.id.show_txt); * show_txt.setText("yong onClick chufa de"); } }); */ btn_send.setOnClickListener(new OnClickListener() { @Override public void onClick(View source) { Intent intent = new Intent(); // acionBar.hide(); /* * Intent intent = new Intent(MainActivity.this, * MainActivity.class); startActivity(intent); */ /* * Toast.makeText(this, "???" + "\n ??" + screen, * Toast.LENGTH_LONG).show(); */ /* * Message msg = new Message(); msg.what = 0x4567; * handler.sendMessage(msg); */ // */ // intent.setClass(MainActivity.this, GestureFlip.class); // */ intent.setClass(MainActivity.this, HTMLActivity.class); // intent.setClass(MainActivity.this, HTMLMainActivity.class); startActivity(intent); } }); btn_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View source) { // acionBar.hide(); Intent intent = new Intent(); // intent.setAction("android.intent.action.OTHERACTIVITY"); // intent.addCategory("android.intent.category.OTHERACTIVITY"); // intent.setAction(Intent.ACTION_MAIN); // intent.addCategory(Intent.CATEGORY_HOME); // intent.setDataAndType(Uri.parse("lee://www.fkjava.org:8888/mypath"),"abc/xyz"); // /ACTION_VIEW /* * / String data = "http://www.baidu.com"; Uri uri = * Uri.parse(data); intent.setAction(Intent.ACTION_VIEW); * intent.setData(uri); / */ // /ACTION_EDIT /* * / intent.setAction(Intent.ACTION_EDIT); * intent.setData(Uri.parse * ("content://com.android.contacts/contacts/1")); // */ // /ACTION_EDIT intent.setAction(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:10086")); // /ACTION_res /* * / intent.setClass(MainActivity.this,ValuesResTest.class); // */ // /ACTION_res /* * / intent.setClass(MainActivity.this, ClipDrawableTest.class); * // */ /* * / intent.setClass(MainActivity.this, LewaBitmapTest.class); * // */ /* * / intent.setClass(MainActivity.this, LewaDrawView.class); // */ /* * / intent.setClass(MainActivity.this, HandDraw.class); // */ /* * / intent.setClass(MainActivity.this, MoveBack.class); // */ /* * / intent.setClass(MainActivity.this, SurfaceViewTest.class); * // */ /* * / intent.setClass(MainActivity.this, DBTest.class); // */ /* * / intent.setClass(MainActivity.this, Dict.class); // */ /* * / intent.setClass(MainActivity.this, GestureZoom.class); // */ // */ // intent.setClass(MainActivity.this, GestureFlip.class); // */ // intent.addCategory("android.intent.category.APP_CALCULATOR"); // PackageManager packageManager = MainActivity.this.getPackageManager(); // try { // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // intent =packageManager.getLaunchIntentForPackage("com.android.calculator2"); // startActivity(intent); // } catch (Exception e) { // Log.i("algerheMain", e.toString()); // } // Intent i = new Intent(Intent.ACTION_MAIN); // i.setComponent(new ComponentName("com.android.calculator2", // "com.android.calculator2.Calculator")); // i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // startActivity(i); } }); }
From source file:com.google.samples.apps.iosched.ui.CurrentSessionActivity.java
@Override public void onStop() { super.onStop(); if (mInitStarred != mStarred) { if (UIUtils.getCurrentTime(this) < mSessionStart) { // Update Calendar event through the Calendar API on Android 4.0 or new versions. Intent intent = null; if (mStarred) { // Set up intent to add session to Calendar, if it doesn't exist already. intent = new Intent(SessionCalendarService.ACTION_ADD_SESSION_CALENDAR, mSessionUri); intent.putExtra(SessionCalendarService.EXTRA_SESSION_START, mSessionStart); intent.putExtra(SessionCalendarService.EXTRA_SESSION_END, mSessionEnd); intent.putExtra(SessionCalendarService.EXTRA_SESSION_ROOM, mRoomName); intent.putExtra(SessionCalendarService.EXTRA_SESSION_TITLE, mTitleString); } else { // Set up intent to remove session from Calendar, if exists. intent = new Intent(SessionCalendarService.ACTION_REMOVE_SESSION_CALENDAR, mSessionUri); intent.putExtra(SessionCalendarService.EXTRA_SESSION_START, mSessionStart); intent.putExtra(SessionCalendarService.EXTRA_SESSION_END, mSessionEnd); intent.putExtra(SessionCalendarService.EXTRA_SESSION_TITLE, mTitleString); }// w w w . ja v a 2 s . c o m intent.setClass(this, SessionCalendarService.class); startService(intent); if (mStarred) { setupNotification(); } } } }
From source file:com.google.samples.apps.iosched.ui.SessionDetailFragment.java
@Override public void onStop() { super.onStop(); if (mInitStarred != mStarred) { if (UIUtils.getCurrentTime(getActivity()) < mSessionStart) { // Update Calendar event through the Calendar API on Android 4.0 or new versions. Intent intent = null; if (mStarred) { // Set up intent to add session to Calendar, if it doesn't exist already. intent = new Intent(SessionCalendarService.ACTION_ADD_SESSION_CALENDAR, mSessionUri); intent.putExtra(SessionCalendarService.EXTRA_SESSION_START, mSessionStart); intent.putExtra(SessionCalendarService.EXTRA_SESSION_END, mSessionEnd); intent.putExtra(SessionCalendarService.EXTRA_SESSION_ROOM, mRoomName); intent.putExtra(SessionCalendarService.EXTRA_SESSION_TITLE, mTitleString); } else { // Set up intent to remove session from Calendar, if exists. intent = new Intent(SessionCalendarService.ACTION_REMOVE_SESSION_CALENDAR, mSessionUri); intent.putExtra(SessionCalendarService.EXTRA_SESSION_START, mSessionStart); intent.putExtra(SessionCalendarService.EXTRA_SESSION_END, mSessionEnd); intent.putExtra(SessionCalendarService.EXTRA_SESSION_TITLE, mTitleString); }// w ww . ja v a 2 s . co m intent.setClass(getActivity(), SessionCalendarService.class); getActivity().startService(intent); if (mStarred) { setupNotification(); } } } }