List of usage examples for android.content Intent FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
To view the source code for android.content Intent FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY.
Click Source Link
From source file:org.telegram.ui.LaunchActivity.java
private void handleIntent(Intent intent, boolean isNew, boolean restore) { boolean pushOpened = false; Integer push_user_id = 0;//from w w w . ja va2 s . c o m Integer push_chat_id = 0; Integer push_enc_id = 0; Integer open_settings = 0; photoPath = null; videoPath = null; sendingText = null; documentPath = null; imagesPathArray = null; documentsPathArray = null; if (intent != null && intent.getAction() != null && !restore) { if (Intent.ACTION_SEND.equals(intent.getAction())) { boolean error = false; String type = intent.getType(); if (type != null && type.equals("text/plain")) { String text = intent.getStringExtra(Intent.EXTRA_TEXT); String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); if (text != null && text.length() != 0) { if ((text.startsWith("http://") || text.startsWith("https://")) && subject != null && subject.length() != 0) { text = subject + "\n" + text; } sendingText = text; } else { error = true; } } else if (type != null && type.equals(ContactsContract.Contacts.CONTENT_VCARD_TYPE)) { try { Uri uri = (Uri) intent.getExtras().get(Intent.EXTRA_STREAM); if (uri != null) { ContentResolver cr = getContentResolver(); InputStream stream = cr.openInputStream(uri); String name = null; String nameEncoding = null; String nameCharset = null; ArrayList<String> phones = new ArrayList<String>(); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(stream, "UTF-8")); String line = null; while ((line = bufferedReader.readLine()) != null) { String[] args = line.split(":"); if (args.length != 2) { continue; } if (args[0].startsWith("FN")) { String[] params = args[0].split(";"); for (String param : params) { String[] args2 = param.split("="); if (args2.length != 2) { continue; } if (args2[0].equals("CHARSET")) { nameCharset = args2[1]; } else if (args2[0].equals("ENCODING")) { nameEncoding = args2[1]; } } name = args[1]; if (nameEncoding != null && nameEncoding.equalsIgnoreCase("QUOTED-PRINTABLE")) { while (name.endsWith("=") && nameEncoding != null) { name = name.substring(0, name.length() - 1); line = bufferedReader.readLine(); if (line == null) { break; } name += line; } byte[] bytes = Utilities.decodeQuotedPrintable(name.getBytes()); if (bytes != null && bytes.length != 0) { String decodedName = new String(bytes, nameCharset); if (decodedName != null) { name = decodedName; } } } } else if (args[0].startsWith("TEL")) { String phone = PhoneFormat.stripExceptNumbers(args[1], true); if (phone.length() > 0) { phones.add(phone); } } } if (name != null && !phones.isEmpty()) { contactsToSend = new ArrayList<TLRPC.User>(); for (String phone : phones) { TLRPC.User user = new TLRPC.TL_userContact(); user.phone = phone; user.first_name = name; user.last_name = ""; user.id = 0; contactsToSend.add(user); } } } else { error = true; } } catch (Exception e) { FileLog.e("tmessages", e); error = true; } } else { Parcelable parcelable = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (parcelable == null) { return; } String path = null; if (!(parcelable instanceof Uri)) { parcelable = Uri.parse(parcelable.toString()); } if (parcelable != null && type != null && type.startsWith("image/")) { photoPath = (Uri) parcelable; } else { path = Utilities.getPath((Uri) parcelable); if (path != null) { if (path.startsWith("file:")) { path = path.replace("file://", ""); } if (type != null && type.startsWith("video/")) { videoPath = path; } else { documentPath = path; } } else { error = true; } } if (error) { Toast.makeText(this, "Unsupported content", Toast.LENGTH_SHORT).show(); } } } else if (intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) { boolean error = false; try { ArrayList<Parcelable> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); String type = intent.getType(); if (uris != null) { if (type != null && type.startsWith("image/")) { Uri[] uris2 = new Uri[uris.size()]; for (int i = 0; i < uris2.length; i++) { Parcelable parcelable = uris.get(i); if (!(parcelable instanceof Uri)) { parcelable = Uri.parse(parcelable.toString()); } uris2[i] = (Uri) parcelable; } imagesPathArray = uris2; } else { String[] uris2 = new String[uris.size()]; for (int i = 0; i < uris2.length; i++) { Parcelable parcelable = uris.get(i); if (!(parcelable instanceof Uri)) { parcelable = Uri.parse(parcelable.toString()); } String path = Utilities.getPath((Uri) parcelable); if (path != null) { if (path.startsWith("file:")) { path = path.replace("file://", ""); } uris2[i] = path; } } documentsPathArray = uris2; } } else { error = true; } } catch (Exception e) { FileLog.e("tmessages", e); error = true; } if (error) { Toast.makeText(this, "Unsupported content", Toast.LENGTH_SHORT).show(); } } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { try { Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null); if (cursor != null) { if (cursor.moveToFirst()) { int userId = cursor.getInt(cursor.getColumnIndex("DATA4")); NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats); push_user_id = userId; } cursor.close(); } } catch (Exception e) { FileLog.e("tmessages", e); } } else if (intent.getAction().equals("org.telegram.messenger.OPEN_ACCOUNT")) { open_settings = 1; } } if (getIntent().getAction() != null && getIntent().getAction().startsWith("com.tmessages.openchat") && (getIntent().getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0 && !restore) { int chatId = getIntent().getIntExtra("chatId", 0); int userId = getIntent().getIntExtra("userId", 0); int encId = getIntent().getIntExtra("encId", 0); if (chatId != 0) { TLRPC.Chat chat = MessagesController.getInstance().chats.get(chatId); if (chat != null) { NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats); push_chat_id = chatId; } } else if (userId != 0) { TLRPC.User user = MessagesController.getInstance().users.get(userId); if (user != null) { NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats); push_user_id = userId; } } else if (encId != 0) { TLRPC.EncryptedChat chat = MessagesController.getInstance().encryptedChats.get(encId); if (chat != null) { NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats); push_enc_id = encId; } } } if (push_user_id != 0) { if (push_user_id == UserConfig.clientUserId) { open_settings = 1; } else { ChatActivity fragment = new ChatActivity(); Bundle bundle = new Bundle(); bundle.putInt("user_id", push_user_id); fragment.setArguments(bundle); if (fragment.onFragmentCreate()) { pushOpened = true; ApplicationLoader.fragmentsStack.add(fragment); getSupportFragmentManager().beginTransaction() .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss(); } } } else if (push_chat_id != 0) { ChatActivity fragment = new ChatActivity(); Bundle bundle = new Bundle(); bundle.putInt("chat_id", push_chat_id); fragment.setArguments(bundle); if (fragment.onFragmentCreate()) { pushOpened = true; ApplicationLoader.fragmentsStack.add(fragment); getSupportFragmentManager().beginTransaction() .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss(); } } else if (push_enc_id != 0) { ChatActivity fragment = new ChatActivity(); Bundle bundle = new Bundle(); bundle.putInt("enc_id", push_enc_id); fragment.setArguments(bundle); if (fragment.onFragmentCreate()) { pushOpened = true; ApplicationLoader.fragmentsStack.add(fragment); getSupportFragmentManager().beginTransaction() .replace(R.id.container, fragment, "chat" + Math.random()).commitAllowingStateLoss(); } } if (videoPath != null || photoPath != null || sendingText != null || documentPath != null || documentsPathArray != null || imagesPathArray != null || contactsToSend != null) { MessagesActivity fragment = new MessagesActivity(); fragment.selectAlertString = R.string.ForwardMessagesTo; fragment.selectAlertStringDesc = "ForwardMessagesTo"; fragment.animationType = 1; Bundle args = new Bundle(); args.putBoolean("onlySelect", true); fragment.setArguments(args); fragment.delegate = this; ApplicationLoader.fragmentsStack.add(fragment); fragment.onFragmentCreate(); getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, fragment.getTag()) .commitAllowingStateLoss(); pushOpened = true; } if (open_settings != 0) { SettingsActivity fragment = new SettingsActivity(); ApplicationLoader.fragmentsStack.add(fragment); fragment.onFragmentCreate(); getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, "settings") .commitAllowingStateLoss(); pushOpened = true; } if (!pushOpened && !isNew) { BaseFragment fragment = ApplicationLoader.fragmentsStack .get(ApplicationLoader.fragmentsStack.size() - 1); getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment, fragment.getTag()) .commitAllowingStateLoss(); } getIntent().setAction(null); }
From source file:org.transdroid.gui.TorrentsFragment.java
private boolean isLaunchedFromHistory(final Intent startIntent) { return (startIntent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0; }
From source file:org.uguess.android.sysinfo.ProcessManager.java
void handleAction(final ProcessItem rap, int action) { Activity ctx = getActivity();//from w w w .ja v a 2 s . c om switch (action) { case ACTION_END: if (!ignoreList.contains(rap.procInfo.processName) && !rap.sys) { ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); String self = ctx.getPackageName(); if (self.equals(rap.procInfo.processName)) { Util.killSelf(handler, ctx, am, self); } else { endProcess(am, rap.procInfo.pkgList, self); handler.removeCallbacks(task); handler.post(task); } } break; case ACTION_END_OTHERS: endAllExcept(rap.procInfo.processName); break; case ACTION_SWITCH: String pkgName = rap.procInfo.processName; if (!pkgName.equals(ctx.getPackageName())) { Intent it = new Intent("android.intent.action.MAIN"); //$NON-NLS-1$ it.addCategory(Intent.CATEGORY_LAUNCHER); List<ResolveInfo> acts = ctx.getPackageManager().queryIntentActivities(it, 0); if (acts != null) { boolean started = false; for (int i = 0, size = acts.size(); i < size; i++) { ResolveInfo ri = acts.get(i); if (pkgName.equals(ri.activityInfo.packageName)) { it.setClassName(ri.activityInfo.packageName, ri.activityInfo.name); it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); try { startActivity(it); started = true; } catch (Exception e) { Log.e(ProcessManager.class.getName(), "Cannot start activity: " + pkgName, //$NON-NLS-1$ e); } break; } } if (!started) { Util.shortToast(ctx, R.string.error_switch_task); } } } break; case ACTION_IGNORE: if (!ignoreList.contains(rap.procInfo.processName) && !rap.sys) { ignoreList.add(rap.procInfo.processName); setIgnoreList(ignoreList); if (IGNORE_ACTION_HIDDEN == Util.getIntOption(ctx, PSTORE_PROCESSMANAGER, PREF_KEY_IGNORE_ACTION, IGNORE_ACTION_HIDDEN)) { handler.removeCallbacks(task); handler.post(task); } } break; case ACTION_DETAILS: String[] status = readProcStatus(rap.procInfo.pid); StringBuffer sb = new StringBuffer().append("<small>") //$NON-NLS-1$ .append(getString(R.string.proc_name)).append(": ") //$NON-NLS-1$ .append(rap.procInfo.processName).append("<br>") //$NON-NLS-1$ .append(getString(R.string.pid)).append(": ") //$NON-NLS-1$ .append(rap.procInfo.pid).append("<br>") //$NON-NLS-1$ .append(getString(R.string.uid)).append(": ") //$NON-NLS-1$ .append(status == null ? "" : status[1]) //$NON-NLS-1$ .append("<br>") //$NON-NLS-1$ .append(getString(R.string.gid)).append(": ") //$NON-NLS-1$ .append(status == null ? "" : status[2]) //$NON-NLS-1$ .append("<br>") //$NON-NLS-1$ .append(getString(R.string.state)).append(": ") //$NON-NLS-1$ .append(status == null ? "" : status[0]) //$NON-NLS-1$ .append("<br>") //$NON-NLS-1$ .append(getString(R.string.threads)).append(": ") //$NON-NLS-1$ .append(status == null ? "" : status[3]) //$NON-NLS-1$ .append("<br>") //$NON-NLS-1$ .append(getString(R.string.importance)).append(": ") //$NON-NLS-1$ .append(rap.procInfo.importance).append("<br>LRU: ") //$NON-NLS-1$ .append(rap.procInfo.lru).append("<br>") //$NON-NLS-1$ .append(getString(R.string.pkg_name)).append(": "); //$NON-NLS-1$ if (rap.procInfo.pkgList != null) { int i = 0; for (String pkg : rap.procInfo.pkgList) { if (pkg != null) { if (i > 0) { sb.append(", "); //$NON-NLS-1$ } sb.append(pkg); i++; } } } sb.append("</small>"); //$NON-NLS-1$ new AlertDialog.Builder(ctx).setTitle(rap.label == null ? rap.procInfo.processName : rap.label) .setNeutralButton(R.string.close, null).setMessage(Html.fromHtml(sb.toString())).create() .show(); break; case ACTION_MENU: final boolean protect = ignoreList.contains(rap.procInfo.processName) || rap.sys; OnClickListener listener = new OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // bypass the 'showMenu' action offset int action = which + 1; if (!protect || (action != ACTION_END && action != ACTION_IGNORE)) { handleAction(rap, action); } } }; new AlertDialog.Builder( ctx).setTitle(R.string.actions) .setItems( new CharSequence[] { getString(R.string.switch_to), protect ? Html.fromHtml("<font color=\"#848484\">" //$NON-NLS-1$ + getString(R.string.end_task) + "</font>") //$NON-NLS-1$ : getString(R.string.end_task), getString(R.string.end_others), protect ? Html.fromHtml("<font color=\"#848484\">" //$NON-NLS-1$ + getString(R.string.ignore) + "</font>") //$NON-NLS-1$ : getString(R.string.ignore), getString(R.string.details) }, listener) .create().show(); break; } }
From source file:com.android.settings.HWSettings.java
@Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); // If it is not launched from history, then reset to top-level if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) { if (mFirstHeader != null && !onIsHidingHeaders() && onIsMultiPane()) { switchToHeaderLocal(mFirstHeader); }/*from www . j av a 2 s .c o m*/ getListView().setSelectionFromTop(0, 0); } }
From source file:org.cafemember.ui.LaunchActivity.java
private boolean handleIntent(Intent intent, boolean isNew, boolean restore, boolean fromPassword) { int flags = intent.getFlags(); if (!fromPassword && (AndroidUtilities.needShowPasscode(true) || UserConfig.isWaitingForPasscodeEnter)) { showPasscodeActivity();//from w w w . j a v a 2 s . c o m passcodeSaveIntent = intent; passcodeSaveIntentIsNew = isNew; passcodeSaveIntentIsRestore = restore; UserConfig.saveConfig(false); } else { boolean pushOpened = false; Integer push_user_id = 0; Integer push_chat_id = 0; Integer push_enc_id = 0; Integer open_settings = 0; long dialogId = intent != null && intent.getExtras() != null ? intent.getExtras().getLong("dialogId", 0) : 0; boolean showDialogsList = false; boolean showPlayer = false; photoPathsArray = null; videoPath = null; sendingText = null; documentsPathsArray = null; documentsOriginalPathsArray = null; documentsMimeType = null; documentsUrisArray = null; contactsToSend = null; if (UserConfig.isClientActivated() && (flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) { if (intent != null && intent.getAction() != null && !restore) { if (Intent.ACTION_SEND.equals(intent.getAction())) { boolean error = false; String type = intent.getType(); if (type != null && type.equals(ContactsContract.Contacts.CONTENT_VCARD_TYPE)) { try { Uri uri = (Uri) intent.getExtras().get(Intent.EXTRA_STREAM); if (uri != null) { ContentResolver cr = getContentResolver(); InputStream stream = cr.openInputStream(uri); String name = null; String nameEncoding = null; String nameCharset = null; ArrayList<String> phones = new ArrayList<>(); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(stream, "UTF-8")); String line; while ((line = bufferedReader.readLine()) != null) { String[] args = line.split(":"); if (args.length != 2) { continue; } if (args[0].startsWith("FN")) { String[] params = args[0].split(";"); for (String param : params) { String[] args2 = param.split("="); if (args2.length != 2) { continue; } if (args2[0].equals("CHARSET")) { nameCharset = args2[1]; } else if (args2[0].equals("ENCODING")) { nameEncoding = args2[1]; } } name = args[1]; if (nameEncoding != null && nameEncoding.equalsIgnoreCase("QUOTED-PRINTABLE")) { while (name.endsWith("=") && nameEncoding != null) { name = name.substring(0, name.length() - 1); line = bufferedReader.readLine(); if (line == null) { break; } name += line; } byte[] bytes = AndroidUtilities .decodeQuotedPrintable(name.getBytes()); if (bytes != null && bytes.length != 0) { String decodedName = new String(bytes, nameCharset); if (decodedName != null) { name = decodedName; } } } } else if (args[0].startsWith("TEL")) { String phone = PhoneFormat.stripExceptNumbers(args[1], true); if (phone.length() > 0) { phones.add(phone); } } } try { bufferedReader.close(); stream.close(); } catch (Exception e) { FileLog.e("tmessages", e); } if (name != null && !phones.isEmpty()) { contactsToSend = new ArrayList<>(); for (String phone : phones) { TLRPC.User user = new TLRPC.TL_userContact_old2(); user.phone = phone; user.first_name = name; user.last_name = ""; user.id = 0; contactsToSend.add(user); } } } else { error = true; } } catch (Exception e) { FileLog.e("tmessages", e); error = true; } } else { String text = intent.getStringExtra(Intent.EXTRA_TEXT); if (text == null) { CharSequence textSequence = intent.getCharSequenceExtra(Intent.EXTRA_TEXT); if (textSequence != null) { text = textSequence.toString(); } } String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); if (text != null && text.length() != 0) { if ((text.startsWith("http://") || text.startsWith("https://")) && subject != null && subject.length() != 0) { text = subject + "\n" + text; } sendingText = text; } else if (subject != null && subject.length() > 0) { sendingText = subject; } Parcelable parcelable = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (parcelable != null) { String path; if (!(parcelable instanceof Uri)) { parcelable = Uri.parse(parcelable.toString()); } Uri uri = (Uri) parcelable; if (uri != null) { if (isInternalUri(uri)) { error = true; } } if (!error) { if (uri != null && (type != null && type.startsWith("image/") || uri.toString().toLowerCase().endsWith(".jpg"))) { if (photoPathsArray == null) { photoPathsArray = new ArrayList<>(); } photoPathsArray.add(uri); } else { path = AndroidUtilities.getPath(uri); if (path != null) { if (path.startsWith("file:")) { path = path.replace("file://", ""); } if (type != null && type.startsWith("video/")) { videoPath = path; } else { if (documentsPathsArray == null) { documentsPathsArray = new ArrayList<>(); documentsOriginalPathsArray = new ArrayList<>(); } documentsPathsArray.add(path); documentsOriginalPathsArray.add(uri.toString()); } } else { if (documentsUrisArray == null) { documentsUrisArray = new ArrayList<>(); } documentsUrisArray.add(uri); documentsMimeType = type; } } if (sendingText != null) { if (sendingText.contains("WhatsApp")) { //remove unnecessary caption 'sent from WhatsApp' from photos forwarded from WhatsApp sendingText = null; } } } } else if (sendingText == null) { error = true; } } if (error) { Toast.makeText(this, "Unsupported content", Toast.LENGTH_SHORT).show(); } } else if (intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) { boolean error = false; try { ArrayList<Parcelable> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); String type = intent.getType(); if (uris != null) { for (int a = 0; a < uris.size(); a++) { Parcelable parcelable = uris.get(a); if (!(parcelable instanceof Uri)) { parcelable = Uri.parse(parcelable.toString()); } Uri uri = (Uri) parcelable; if (uri != null) { if (isInternalUri(uri)) { uris.remove(a); a--; } } } if (uris.isEmpty()) { uris = null; } } if (uris != null) { if (type != null && type.startsWith("image/")) { for (int a = 0; a < uris.size(); a++) { Parcelable parcelable = uris.get(a); if (!(parcelable instanceof Uri)) { parcelable = Uri.parse(parcelable.toString()); } Uri uri = (Uri) parcelable; if (photoPathsArray == null) { photoPathsArray = new ArrayList<>(); } photoPathsArray.add(uri); } } else { for (int a = 0; a < uris.size(); a++) { Parcelable parcelable = uris.get(a); if (!(parcelable instanceof Uri)) { parcelable = Uri.parse(parcelable.toString()); } String path = AndroidUtilities.getPath((Uri) parcelable); String originalPath = parcelable.toString(); if (originalPath == null) { originalPath = path; } if (path != null) { if (path.startsWith("file:")) { path = path.replace("file://", ""); } if (documentsPathsArray == null) { documentsPathsArray = new ArrayList<>(); documentsOriginalPathsArray = new ArrayList<>(); } documentsPathsArray.add(path); documentsOriginalPathsArray.add(originalPath); } } } } else { error = true; } } catch (Exception e) { FileLog.e("tmessages", e); error = true; } if (error) { Toast.makeText(this, "Unsupported content", Toast.LENGTH_SHORT).show(); } } else if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri data = intent.getData(); if (data != null) { String username = null; String group = null; String sticker = null; String botUser = null; String botChat = null; String message = null; Integer messageId = null; boolean hasUrl = false; String scheme = data.getScheme(); if (scheme != null) { if ((scheme.equals("http") || scheme.equals("https"))) { String host = data.getHost().toLowerCase(); if (host.equals("telegram.me") || host.equals("telegram.dog")) { String path = data.getPath(); if (path != null && path.length() > 1) { path = path.substring(1); if (path.startsWith("joinchat/")) { group = path.replace("joinchat/", ""); } else if (path.startsWith("addstickers/")) { sticker = path.replace("addstickers/", ""); } else if (path.startsWith("msg/") || path.startsWith("share/")) { message = data.getQueryParameter("url"); if (message == null) { message = ""; } if (data.getQueryParameter("text") != null) { if (message.length() > 0) { hasUrl = true; message += "\n"; } message += data.getQueryParameter("text"); } } else if (path.length() >= 1) { List<String> segments = data.getPathSegments(); if (segments.size() > 0) { username = segments.get(0); if (segments.size() > 1) { messageId = Utilities.parseInt(segments.get(1)); if (messageId == 0) { messageId = null; } } } botUser = data.getQueryParameter("start"); botChat = data.getQueryParameter("startgroup"); } } } } else if (scheme.equals("tg")) { String url = data.toString(); if (url.startsWith("tg:resolve") || url.startsWith("tg://resolve")) { url = url.replace("tg:resolve", "tg://telegram.org").replace("tg://resolve", "tg://telegram.org"); data = Uri.parse(url); username = data.getQueryParameter("domain"); botUser = data.getQueryParameter("start"); botChat = data.getQueryParameter("startgroup"); } else if (url.startsWith("tg:join") || url.startsWith("tg://join")) { url = url.replace("tg:join", "tg://telegram.org").replace("tg://join", "tg://telegram.org"); data = Uri.parse(url); group = data.getQueryParameter("invite"); } else if (url.startsWith("tg:addstickers") || url.startsWith("tg://addstickers")) { url = url.replace("tg:addstickers", "tg://telegram.org") .replace("tg://addstickers", "tg://telegram.org"); data = Uri.parse(url); sticker = data.getQueryParameter("set"); } else if (url.startsWith("tg:msg") || url.startsWith("tg://msg") || url.startsWith("tg://share") || url.startsWith("tg:share")) { url = url.replace("tg:msg", "tg://telegram.org") .replace("tg://msg", "tg://telegram.org") .replace("tg://share", "tg://telegram.org") .replace("tg:share", "tg://telegram.org"); data = Uri.parse(url); message = data.getQueryParameter("url"); if (message == null) { message = ""; } if (data.getQueryParameter("text") != null) { if (message.length() > 0) { hasUrl = true; message += "\n"; } message += data.getQueryParameter("text"); } } } } if (username != null || group != null || sticker != null || message != null) { runLinkRequest(username, group, sticker, botUser, botChat, message, hasUrl, messageId, 0); } else { try { Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null); if (cursor != null) { if (cursor.moveToFirst()) { int userId = cursor.getInt(cursor.getColumnIndex("DATA4")); NotificationCenter.getInstance() .postNotificationName(NotificationCenter.closeChats); push_user_id = userId; } cursor.close(); } } catch (Exception e) { FileLog.e("tmessages", e); } } } } else if (intent.getAction().equals("org.telegram.messenger.OPEN_ACCOUNT")) { open_settings = 1; } else if (intent.getAction().startsWith("com.tmessages.openchat")) { int chatId = intent.getIntExtra("chatId", 0); int userId = intent.getIntExtra("userId", 0); int encId = intent.getIntExtra("encId", 0); if (chatId != 0) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); push_chat_id = chatId; } else if (userId != 0) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); push_user_id = userId; } else if (encId != 0) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); push_enc_id = encId; } else { showDialogsList = true; } } else if (intent.getAction().equals("com.tmessages.openplayer")) { showPlayer = true; } } } if (push_user_id != 0) { Bundle args = new Bundle(); args.putInt("user_id", push_user_id); if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) { ChatActivity fragment = new ChatActivity(args); if (actionBarLayout.presentFragment(fragment, false, true, true)) { pushOpened = true; } } } else if (push_chat_id != 0) { Bundle args = new Bundle(); args.putInt("chat_id", push_chat_id); if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args, mainFragmentsStack.get(mainFragmentsStack.size() - 1))) { ChatActivity fragment = new ChatActivity(args); if (actionBarLayout.presentFragment(fragment, false, true, true)) { pushOpened = true; } } } else if (push_enc_id != 0) { Bundle args = new Bundle(); args.putInt("enc_id", push_enc_id); ChatActivity fragment = new ChatActivity(args); if (actionBarLayout.presentFragment(fragment, false, true, true)) { pushOpened = true; } } else if (showDialogsList) { if (!AndroidUtilities.isTablet()) { actionBarLayout.removeAllFragments(); } else { if (!layersActionBarLayout.fragmentsStack.isEmpty()) { for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) { layersActionBarLayout .removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0)); a--; } layersActionBarLayout.closeLastFragment(false); } } pushOpened = false; isNew = false; } else if (showPlayer) { if (AndroidUtilities.isTablet()) { for (int a = 0; a < layersActionBarLayout.fragmentsStack.size(); a++) { BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(a); if (fragment instanceof AudioPlayerActivity) { layersActionBarLayout.removeFragmentFromStack(fragment); break; } } actionBarLayout.showLastFragment(); rightActionBarLayout.showLastFragment(); drawerLayoutContainer.setAllowOpenDrawer(false, false); } else { for (int a = 0; a < actionBarLayout.fragmentsStack.size(); a++) { BaseFragment fragment = actionBarLayout.fragmentsStack.get(a); if (fragment instanceof AudioPlayerActivity) { actionBarLayout.removeFragmentFromStack(fragment); break; } } drawerLayoutContainer.setAllowOpenDrawer(true, false); } actionBarLayout.presentFragment(new AudioPlayerActivity(), false, true, true); pushOpened = true; } else if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null || documentsUrisArray != null) { if (!AndroidUtilities.isTablet()) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); } if (dialogId == 0) { Bundle args = new Bundle(); args.putBoolean("onlySelect", true); if (contactsToSend != null) { args.putString("selectAlertString", LocaleController.getString("SendContactTo", R.string.SendMessagesTo)); args.putString("selectAlertStringGroup", LocaleController.getString("SendContactToGroup", R.string.SendContactToGroup)); } else { args.putString("selectAlertString", LocaleController.getString("SendMessagesTo", R.string.SendMessagesTo)); args.putString("selectAlertStringGroup", LocaleController.getString("SendMessagesToGroup", R.string.SendMessagesToGroup)); } DialogsActivity fragment = new DialogsActivity(args); dialogsFragment = fragment; fragment.setDelegate(this); boolean removeLast; if (AndroidUtilities.isTablet()) { removeLast = layersActionBarLayout.fragmentsStack.size() > 0 && layersActionBarLayout.fragmentsStack.get( layersActionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity; } else { removeLast = actionBarLayout.fragmentsStack.size() > 1 && actionBarLayout.fragmentsStack .get(actionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity; } actionBarLayout.presentFragment(fragment, removeLast, true, true); pushOpened = true; if (PhotoViewer.getInstance().isVisible()) { PhotoViewer.getInstance().closePhoto(false, true); } drawerLayoutContainer.setAllowOpenDrawer(false, false); if (AndroidUtilities.isTablet()) { actionBarLayout.showLastFragment(); rightActionBarLayout.showLastFragment(); } else { drawerLayoutContainer.setAllowOpenDrawer(true, false); } } else { didSelectDialog(null, dialogId, false); } } else if (open_settings != 0) { actionBarLayout.presentFragment(new SettingsActivity(), false, true, true); if (AndroidUtilities.isTablet()) { actionBarLayout.showLastFragment(); rightActionBarLayout.showLastFragment(); drawerLayoutContainer.setAllowOpenDrawer(false, false); } else { drawerLayoutContainer.setAllowOpenDrawer(true, false); } pushOpened = true; } if (!pushOpened && !isNew) { if (AndroidUtilities.isTablet()) { if (!UserConfig.isClientActivated()) { if (layersActionBarLayout.fragmentsStack.isEmpty()) { layersActionBarLayout.addFragmentToStack(new LoginActivity()); drawerLayoutContainer.setAllowOpenDrawer(false, false); } } else { if (actionBarLayout.fragmentsStack.isEmpty()) { actionBarLayout.addFragmentToStack(new DialogsActivity(null)); drawerLayoutContainer.setAllowOpenDrawer(true, false); } } } else { if (actionBarLayout.fragmentsStack.isEmpty()) { if (!UserConfig.isClientActivated()) { actionBarLayout.addFragmentToStack(new LoginActivity()); drawerLayoutContainer.setAllowOpenDrawer(false, false); } else { actionBarLayout.addFragmentToStack(new DialogsActivity(null)); drawerLayoutContainer.setAllowOpenDrawer(true, false); } } } actionBarLayout.showLastFragment(); if (AndroidUtilities.isTablet()) { layersActionBarLayout.showLastFragment(); rightActionBarLayout.showLastFragment(); } } intent.setAction(null); return pushOpened; } return false; }
From source file:com.android.contacts.activities.DialtactsActivity.java
/** * Stores the filter text associated with a FILTER_CONTACTS_ACTION intent. * This is so child activities can check if they are supposed to display a filter. * * @param intent The intent received in {@link #onNewIntent(Intent)} *///w ww . j av a2 s .c o m private void setupFilterText(Intent intent) { // If the intent was relaunched from history, don't apply the filter text. if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) { return; } String filter = intent.getStringExtra(UI.FILTER_TEXT_EXTRA_KEY); if (filter != null && filter.length() > 0) { mFilterText = filter; } }
From source file:jackpal.androidterm.Term.java
@Override protected void onNewIntent(Intent intent) { if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) { // Don't repeat action if intent comes from history return;//from w w w . j av a2s .c om } String action = intent.getAction(); if (TextUtils.isEmpty(action) || !mPrivateAlias.equals(intent.getComponent())) { return; } // huge number simply opens new window // TODO: add a way to restrict max number of windows per caller (possibly via reusing BoundSession) switch (action) { case RemoteInterface.PRIVACT_OPEN_NEW_WINDOW: onResumeSelectWindow = Integer.MAX_VALUE; break; case RemoteInterface.PRIVACT_SWITCH_WINDOW: int target = intent.getIntExtra(RemoteInterface.PRIVEXTRA_TARGET_WINDOW, -1); if (target >= 0) { onResumeSelectWindow = target; } else { onResumeSelectWindowHandle = intent.getStringExtra(RemoteInterface.EXTRA_WINDOW_HANDLE); } break; } }