List of usage examples for android.content Intent ACTION_CREATE_SHORTCUT
String ACTION_CREATE_SHORTCUT
To view the source code for android.content Intent ACTION_CREATE_SHORTCUT.
Click Source Link
From source file:com.jefftharris.passwdsafe.PreferencesFragment.java
@Override public boolean onPreferenceClick(Preference preference) { switch (preference.getKey()) { case Preferences.PREF_DEF_FILE: { Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT, null, getContext(), LauncherFileShortcuts.class); intent.putExtra(LauncherFileShortcuts.EXTRA_IS_DEFAULT_FILE, true); startActivityForResult(intent, REQUEST_DEFAULT_FILE); return true; }//from w ww .j a v a 2s. c o m case Preferences.PREF_PASSWD_CLEAR_ALL_NOTIFS: { Activity act = getActivity(); PasswdSafeApp app = (PasswdSafeApp) act.getApplication(); Bundle confirmArgs = new Bundle(); confirmArgs.putString(CONFIRM_ARG_ACTION, ConfirmAction.CLEAR_ALL_NOTIFS.name()); DialogFragment dlg = app.getNotifyMgr().createClearAllPrompt(act, confirmArgs); dlg.setTargetFragment(this, REQUEST_CLEAR_ALL_NOTIFS); dlg.show(getFragmentManager(), "clearNotifsConfirm"); return true; } case Preferences.PREF_PASSWD_CLEAR_ALL_SAVED: { Bundle confirmArgs = new Bundle(); confirmArgs.putString(CONFIRM_ARG_ACTION, ConfirmAction.CLEAR_ALL_SAVED.name()); ConfirmPromptDialog dlg = ConfirmPromptDialog.newInstance(getString(R.string.clear_all_saved_passwords), getString(R.string.erase_all_saved_passwords), getString(R.string.clear), confirmArgs); dlg.setTargetFragment(this, REQUEST_CLEAR_ALL_SAVED); dlg.show(getFragmentManager(), "clearSavedConfirm"); return true; } } return false; }
From source file:nl.mpcjanssen.simpletask.AddTask.java
@Override public void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate()"); m_app = (TodoApplication) getApplication(); m_app.setActionBarStyle(getWindow()); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.BROADCAST_UPDATE_UI); intentFilter.addAction(Constants.BROADCAST_SYNC_START); intentFilter.addAction(Constants.BROADCAST_SYNC_DONE); localBroadcastManager = m_app.getLocalBroadCastManager(); m_broadcastReceiver = new BroadcastReceiver() { @Override/* w w w . jav a 2 s . c o m*/ public void onReceive(Context context, @NotNull Intent intent) { if (intent.getAction().equals(Constants.BROADCAST_SYNC_START)) { setProgressBarIndeterminateVisibility(true); } else if (intent.getAction().equals(Constants.BROADCAST_SYNC_DONE)) { setProgressBarIndeterminateVisibility(false); } } }; localBroadcastManager.registerReceiver(m_broadcastReceiver, intentFilter); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } final Intent intent = getIntent(); ActiveFilter mFilter = new ActiveFilter(); mFilter.initFromIntent(intent); final String action = intent.getAction(); // create shortcut and exit if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) { Log.d(TAG, "Setting up shortcut icon"); setupShortcut(); finish(); return; } else if (Intent.ACTION_SEND.equals(action)) { Log.d(TAG, "Share"); if (intent.hasExtra(Intent.EXTRA_TEXT)) { share_text = intent.getCharSequenceExtra(Intent.EXTRA_TEXT).toString(); } else { share_text = ""; } if (!m_app.hasShareTaskShowsEdit()) { if (!share_text.equals("")) { addBackgroundTask(share_text); } finish(); return; } } else if ("com.google.android.gm.action.AUTO_SEND".equals(action)) { // Called as note to self from google search/now noteToSelf(intent); finish(); return; } else if (Constants.INTENT_BACKGROUND_TASK.equals(action)) { Log.v(TAG, "Adding background task"); if (intent.hasExtra(Constants.EXTRA_BACKGROUND_TASK)) { addBackgroundTask(intent.getStringExtra(Constants.EXTRA_BACKGROUND_TASK)); } else { Log.w(TAG, "Task was not in extras"); } finish(); return; } getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); setContentView(R.layout.add_task); // text textInputField = (EditText) findViewById(R.id.taskText); m_app.setEditTextHint(textInputField, R.string.tasktexthint); if (share_text != null) { textInputField.setText(share_text); } Task iniTask = null; setTitle(R.string.addtask); m_backup = m_app.getTaskCache(this).getTasksToUpdate(); if (m_backup != null && m_backup.size() > 0) { ArrayList<String> prefill = new ArrayList<String>(); for (Task t : m_backup) { prefill.add(t.inFileFormat()); } String sPrefill = Util.join(prefill, "\n"); textInputField.setText(sPrefill); setTitle(R.string.updatetask); } else { if (textInputField.getText().length() == 0) { iniTask = new Task(1, ""); iniTask.initWithFilter(mFilter); } if (iniTask != null && iniTask.getTags().size() == 1) { List<String> ps = iniTask.getTags(); String project = ps.get(0); if (!project.equals("-")) { textInputField.append(" +" + project); } } if (iniTask != null && iniTask.getLists().size() == 1) { List<String> cs = iniTask.getLists(); String context = cs.get(0); if (!context.equals("-")) { textInputField.append(" @" + context); } } } // Listen to enter events, use IME_ACTION_NEXT for soft keyboards // like Swype where ENTER keyCode is not generated. int inputFlags = InputType.TYPE_CLASS_TEXT; if (m_app.hasCapitalizeTasks()) { inputFlags |= InputType.TYPE_TEXT_FLAG_CAP_SENTENCES; } textInputField.setRawInputType(inputFlags); textInputField.setImeOptions(EditorInfo.IME_ACTION_NEXT); textInputField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int actionId, @Nullable KeyEvent keyEvent) { boolean hardwareEnterUp = keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_UP && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER; boolean hardwareEnterDown = keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_DOWN && keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER; boolean imeActionNext = (actionId == EditorInfo.IME_ACTION_NEXT); if (imeActionNext || hardwareEnterUp) { // Move cursor to end of line int position = textInputField.getSelectionStart(); String remainingText = textInputField.getText().toString().substring(position); int endOfLineDistance = remainingText.indexOf('\n'); int endOfLine; if (endOfLineDistance == -1) { endOfLine = textInputField.length(); } else { endOfLine = position + endOfLineDistance; } textInputField.setSelection(endOfLine); replaceTextAtSelection("\n", false); if (hasCloneTags()) { String precedingText = textInputField.getText().toString().substring(0, endOfLine); int lineStart = precedingText.lastIndexOf('\n'); String line; if (lineStart != -1) { line = precedingText.substring(lineStart, endOfLine); } else { line = precedingText; } Task t = new Task(0, line); LinkedHashSet<String> tags = new LinkedHashSet<String>(); for (String ctx : t.getLists()) { tags.add("@" + ctx); } for (String prj : t.getTags()) { tags.add("+" + prj); } replaceTextAtSelection(Util.join(tags, " "), true); } endOfLine++; textInputField.setSelection(endOfLine); } return (imeActionNext || hardwareEnterDown || hardwareEnterUp); } }); setCloneTags(m_app.isAddTagsCloneTags()); setWordWrap(m_app.isWordWrap()); findViewById(R.id.cb_wrap).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setWordWrap(hasWordWrap()); } }); int textIndex = 0; textInputField.setSelection(textIndex); // Set button callbacks findViewById(R.id.btnContext).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showContextMenu(); } }); findViewById(R.id.btnProject).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showTagMenu(); } }); findViewById(R.id.btnPrio).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showPrioMenu(); } }); findViewById(R.id.btnDue).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { insertDate(Task.DUE_DATE); } }); findViewById(R.id.btnThreshold).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { insertDate(Task.THRESHOLD_DATE); } }); if (m_backup != null && m_backup.size() > 0) { textInputField.setSelection(textInputField.getText().length()); } }
From source file:com.xabber.android.ui.ContactList.java
@Override protected void onResume() { super.onResume(); barPainter.setDefaultColor();/*from w ww . j a v a 2 s . c o m*/ rebuildAccountToggle(); Application.getInstance().addUIListener(OnAccountChangedListener.class, this); if (action != null) { switch (action) { case ContactList.ACTION_ROOM_INVITE: case Intent.ACTION_SEND: case Intent.ACTION_CREATE_SHORTCUT: if (Intent.ACTION_SEND.equals(action)) { sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT); } Toast.makeText(this, getString(R.string.select_contact), Toast.LENGTH_LONG).show(); break; case Intent.ACTION_VIEW: { action = null; Uri data = getIntent().getData(); if (data != null && "xmpp".equals(data.getScheme())) { XMPPUri xmppUri; try { xmppUri = XMPPUri.parse(data); } catch (IllegalArgumentException e) { xmppUri = null; } if (xmppUri != null && "message".equals(xmppUri.getQueryType())) { ArrayList<String> texts = xmppUri.getValues("body"); String text = null; if (texts != null && !texts.isEmpty()) { text = texts.get(0); } openChat(xmppUri.getPath(), text); } } break; } case Intent.ACTION_SENDTO: { action = null; Uri data = getIntent().getData(); if (data != null) { String path = data.getPath(); if (path != null && path.startsWith("/")) { openChat(path.substring(1), null); } } break; } } } if (Application.getInstance().doNotify()) { if (!SettingsManager.isTranslationSuggested()) { Locale currentLocale = getResources().getConfiguration().locale; if (!currentLocale.getLanguage().equals("en") && !getResources().getBoolean(R.bool.is_translated)) { new TranslationDialog().show(getFragmentManager(), "TRANSLATION_DIALOG"); SettingsManager.setTranslationSuggested(); } } if (SettingsManager.bootCount() > 2 && !SettingsManager.connectionStartAtBoot() && !SettingsManager.startAtBootSuggested()) { StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT"); } if (!SettingsManager.contactIntegrationSuggested() && Application.getInstance().isContactsSupported()) { if (AccountManager.getInstance().getAllAccounts().isEmpty()) { SettingsManager.setContactIntegrationSuggested(); } else { ContactIntegrationDialogFragment.newInstance().show(getFragmentManager(), "CONTACT_INTEGRATION"); } } } }
From source file:com.xabber.android.ui.activity.ContactList.java
@Override protected void onResume() { super.onResume(); barPainter.setDefaultColor();//from w w w.j av a 2 s .c o m rebuildAccountToggle(); Application.getInstance().addUIListener(OnAccountChangedListener.class, this); if (action != null) { switch (action) { case ContactList.ACTION_ROOM_INVITE: case Intent.ACTION_SEND: case Intent.ACTION_CREATE_SHORTCUT: if (Intent.ACTION_SEND.equals(action)) { sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT); } Toast.makeText(this, getString(R.string.select_contact), Toast.LENGTH_LONG).show(); break; case Intent.ACTION_VIEW: { action = null; Uri data = getIntent().getData(); if (data != null && "xmpp".equals(data.getScheme())) { XMPPUri xmppUri; try { xmppUri = XMPPUri.parse(data); } catch (IllegalArgumentException e) { xmppUri = null; } if (xmppUri != null && "message".equals(xmppUri.getQueryType())) { ArrayList<String> texts = xmppUri.getValues("body"); String text = null; if (texts != null && !texts.isEmpty()) { text = texts.get(0); } openChat(xmppUri.getPath(), text); } } break; } case Intent.ACTION_SENDTO: { action = null; Uri data = getIntent().getData(); if (data != null) { String path = data.getPath(); if (path != null && path.startsWith("/")) { openChat(path.substring(1), null); } } break; } case ContactList.ACTION_MUC_PRIVATE_CHAT_INVITE: action = null; showMucPrivateChatDialog(); break; case ContactList.ACTION_CONTACT_SUBSCRIPTION: action = null; showContactSubscriptionDialog(); break; case ContactList.ACTION_INCOMING_MUC_INVITE: action = null; showMucInviteDialog(); break; } } if (Application.getInstance().doNotify()) { if (!SettingsManager.isTranslationSuggested()) { Locale currentLocale = getResources().getConfiguration().locale; if (!currentLocale.getLanguage().equals("en") && !getResources().getBoolean(R.bool.is_translated)) { new TranslationDialog().show(getFragmentManager(), "TRANSLATION_DIALOG"); SettingsManager.setTranslationSuggested(); } } if (SettingsManager.bootCount() > 2 && !SettingsManager.connectionStartAtBoot() && !SettingsManager.startAtBootSuggested()) { StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT"); } if (SettingsManager.interfaceTheme() != SettingsManager.InterfaceTheme.dark) { if (!SettingsManager.isDarkThemeSuggested() && SettingsManager.bootCount() > 0) { new DarkThemeIntroduceDialog().show(getFragmentManager(), DarkThemeIntroduceDialog.class.getSimpleName()); SettingsManager.setDarkThemeSuggested(); } } else { SettingsManager.setDarkThemeSuggested(); } if (!SettingsManager.contactIntegrationSuggested() && Application.getInstance().isContactsSupported()) { if (AccountManager.getInstance().getAllAccounts().isEmpty()) { SettingsManager.setContactIntegrationSuggested(); } else { ContactIntegrationDialogFragment.newInstance().show(getFragmentManager(), "CONTACT_INTEGRATION"); } } } }
From source file:com.xabber.android.ui.activity.ContactListActivity.java
@Override protected void onResume() { super.onResume(); if (!AccountManager.getInstance().hasAccounts()) { startActivity(IntroActivity.createIntent(this)); finish();// ww w .j ava 2s. co m return; } barPainter.setDefaultColor(); rebuildAccountToggle(); Application.getInstance().addUIListener(OnAccountChangedListener.class, this); if (action != null) { switch (action) { case ContactListActivity.ACTION_ROOM_INVITE: case Intent.ACTION_SEND: case Intent.ACTION_CREATE_SHORTCUT: if (Intent.ACTION_SEND.equals(action)) { sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT); } Toast.makeText(this, getString(R.string.select_contact), Toast.LENGTH_LONG).show(); break; case Intent.ACTION_VIEW: { action = null; Uri data = getIntent().getData(); if (data != null && "xmpp".equals(data.getScheme())) { XMPPUri xmppUri; try { xmppUri = XMPPUri.parse(data); } catch (IllegalArgumentException e) { xmppUri = null; } if (xmppUri != null && "message".equals(xmppUri.getQueryType())) { ArrayList<String> texts = xmppUri.getValues("body"); String text = null; if (texts != null && !texts.isEmpty()) { text = texts.get(0); } UserJid user = null; try { user = UserJid.from(xmppUri.getPath()); } catch (UserJid.UserJidCreateException e) { LogManager.exception(this, e); } if (user != null) { openChat(user, text); } } } break; } case Intent.ACTION_SENDTO: { action = null; Uri data = getIntent().getData(); if (data != null) { String path = data.getPath(); if (path != null && path.startsWith("/")) { try { UserJid user = UserJid.from(path.substring(1)); openChat(user, null); } catch (UserJid.UserJidCreateException e) { LogManager.exception(this, e); } } } break; } case ContactListActivity.ACTION_MUC_PRIVATE_CHAT_INVITE: action = null; showMucPrivateChatDialog(); break; case ContactListActivity.ACTION_CONTACT_SUBSCRIPTION: action = null; showContactSubscriptionDialog(); break; case ContactListActivity.ACTION_INCOMING_MUC_INVITE: action = null; showMucInviteDialog(); break; } } if (Application.getInstance().doNotify()) { if (BatteryHelper.isOptimizingBattery() && !SettingsManager.isBatteryOptimizationDisableSuggested()) { BatteryOptimizationDisableDialog.newInstance().show(getFragmentManager(), BatteryOptimizationDisableDialog.class.getSimpleName()); } if (!SettingsManager.isTranslationSuggested()) { Locale currentLocale = getResources().getConfiguration().locale; if (!currentLocale.getLanguage().equals("en") && !getResources().getBoolean(R.bool.is_translated)) { new TranslationDialog().show(getFragmentManager(), "TRANSLATION_DIALOG"); } } if (SettingsManager.isCrashReportsSupported() && !SettingsManager.isCrashReportsDialogShown()) { CrashReportDialog.newInstance().show(getFragmentManager(), CrashReportDialog.class.getSimpleName()); } if (SettingsManager.interfaceTheme() != SettingsManager.InterfaceTheme.dark) { if (!SettingsManager.isDarkThemeSuggested() && SettingsManager.bootCount() > 1) { new DarkThemeIntroduceDialog().show(getFragmentManager(), DarkThemeIntroduceDialog.class.getSimpleName()); } } else { SettingsManager.setDarkThemeSuggested(); } if (SettingsManager.bootCount() > 2 && !SettingsManager.connectionStartAtBoot() && !SettingsManager.startAtBootSuggested()) { StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT"); } } }
From source file:org.openintents.notepad.NoteEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (DEBUG) {/*ww w . ja v a 2 s . c o m*/ Log.d(TAG, "onCreate()"); } if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) { createShortcut(); return; } if (savedInstanceState == null) { // sDecryptedText has no use for brand new activities sDecryptedText = null; } // Usually, sDecryptedText == null. mDecryptedText = sDecryptedText; if (sDecryptedText != null) { // we use the text right now, // so don't encrypt the text anymore. EncryptActivity.cancelEncrypt(); if (EncryptActivity.getPendingEncryptActivities() == 0) { if (DEBUG) { Log.d(TAG, "sDecryptedText = null"); } // no more encrypt activies will be called sDecryptedText = null; } } mSelectionStart = 0; mSelectionStop = 0; // If an instance of this activity had previously stopped, we can // get the original text it started with. if (savedInstanceState != null) { mOriginalContent = savedInstanceState.getString(BUNDLE_ORIGINAL_CONTENT); mUndoRevert = savedInstanceState.getString(BUNDLE_UNDO_REVERT); mState = savedInstanceState.getInt(BUNDLE_STATE); String uriString = savedInstanceState.getString(BUNDLE_URI); if (uriString != null) { mUri = Uri.parse(uriString); } mSelectionStart = savedInstanceState.getInt(BUNDLE_SELECTION_START); mSelectionStop = savedInstanceState.getInt(BUNDLE_SELECTION_STOP); mFileContent = savedInstanceState.getString(BUNDLE_FILE_CONTENT); if (mApplyText == null && mApplyTextBefore == null && mApplyTextAfter == null) { // Only read values if they had not been set by // onActivityResult() yet: mApplyText = savedInstanceState.getString(BUNDLE_APPLY_TEXT); mApplyTextBefore = savedInstanceState.getString(BUNDLE_APPLY_TEXT_BEFORE); mApplyTextAfter = savedInstanceState.getString(BUNDLE_APPLY_TEXT_AFTER); } } else { // Do some setup based on the action being performed. final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_EDIT.equals(action) || Intent.ACTION_VIEW.equals(action)) { // Requested to edit: set that state, and the data being edited. mState = STATE_EDIT; mUri = intent.getData(); if (mUri != null && mUri.getScheme().equals("file")) { mState = STATE_EDIT_NOTE_FROM_SDCARD; // Load the file into a new note. if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { mFileContent = readFile(FileUriUtils.getFile(mUri)); } else { if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_CODE_PERMISSION_READ_EXTERNAL_STORAGE); mFileContent = getString(R.string.request_permissions); } } } else if (mUri != null && !mUri.getAuthority().equals(NotePad.AUTHORITY)) { // Note a notepad note. Treat slightly differently. // (E.g. a note from OI Shopping List) mState = STATE_EDIT_EXTERNAL_NOTE; } } else if (Intent.ACTION_INSERT.equals(action) || Intent.ACTION_SEND.equals(action)) { // Use theme of most recently modified note: ContentValues values = new ContentValues(1); String theme = getMostRecentlyUsedTheme(); values.put(Notes.THEME, theme); String tags = intent.getStringExtra(NotepadInternalIntents.EXTRA_TAGS); values.put(Notes.TAGS, tags); if (mText != null) { values.put(Notes.SELECTION_START, mText.getSelectionStart()); values.put(Notes.SELECTION_END, mText.getSelectionEnd()); } // Requested to insert: set that state, and create a new entry // in the container. mState = STATE_INSERT; /* * intent.setAction(Intent.ACTION_EDIT); intent.setData(mUri); * setIntent(intent); */ if (Intent.ACTION_SEND.equals(action)) { values.put(Notes.NOTE, getIntent().getStringExtra(Intent.EXTRA_TEXT)); mUri = getContentResolver().insert(Notes.CONTENT_URI, values); } else { mUri = getContentResolver().insert(intent.getData(), values); } // If we were unable to create a new note, then just finish // this activity. A RESULT_CANCELED will be sent back to the // original activity if they requested a result. if (mUri == null) { Log.e(TAG, "Failed to insert new note into " + getIntent().getData()); finish(); return; } // The new entry was created, so assume all will end well and // set the result to be returned. // setResult(RESULT_OK, (new // Intent()).setAction(mUri.toString())); setResult(RESULT_OK, intent); } else { // Whoops, unknown action! Bail. Log.e(TAG, "Unknown action, exiting"); finish(); return; } } // setup actionbar if (mActionBarAvailable) { requestWindowFeature(Window.FEATURE_ACTION_BAR); WrapActionBar bar = new WrapActionBar(this); bar.setDisplayHomeAsUpEnabled(true); // force to show the actionbar on version 14+ if (Integer.valueOf(android.os.Build.VERSION.SDK) >= 14) { bar.setHomeButtonEnabled(true); } } else { requestWindowFeature(Window.FEATURE_RIGHT_ICON); } // Set the layout for this activity. You can find it in // res/layout/note_editor.xml setContentView(R.layout.note_editor); // The text view for our note, identified by its ID in the XML file. mText = (EditText) findViewById(R.id.note); if (mState == STATE_EDIT_NOTE_FROM_SDCARD) { // We add a text watcher, so that the title can be updated // to indicate a small "*" if modified. mText.addTextChangedListener(mTextWatcherSdCard); } if (mState != STATE_EDIT_NOTE_FROM_SDCARD) { // Check if we load a note from notepad or from some external module if (mState == STATE_EDIT_EXTERNAL_NOTE) { // Get all the columns as we don't know which columns are // supported. mCursor = managedQuery(mUri, null, null, null, null); // Now check which columns are available List<String> columnNames = Arrays.asList(mCursor.getColumnNames()); if (!columnNames.contains(Notes.NOTE)) { hasNoteColumn = false; } if (!columnNames.contains(Notes.TAGS)) { hasTagsColumn = false; } if (!columnNames.contains(Notes.ENCRYPTED)) { hasEncryptionColumn = false; } if (!columnNames.contains(Notes.THEME)) { hasThemeColumn = false; } if (!columnNames.contains(Notes.SELECTION_START)) { hasSelection_startColumn = false; } if (!columnNames.contains(Notes.SELECTION_END)) { hasSelection_endColumn = false; } } else { // Get the note! mCursor = managedQuery(mUri, PROJECTION, null, null, null); // It's not an external note, so all the columns are available // in the database } } else { mCursor = null; } mText.addTextChangedListener(mTextWatcherCharCount); initSearchPanel(); }
From source file:com.android.launcher2.AsyncTaskCallback.java
public void onPackagesUpdated() { // Get the list of widgets and shortcuts mWidgets.clear();/*ww w . j a v a 2 s . c o m*/ List<AppWidgetProviderInfo> widgets = AppWidgetManager.getInstance(mLauncher).getInstalledProviders(); Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT); List<ResolveInfo> shortcuts = mPackageManager.queryIntentActivities(shortcutsIntent, 0); addInstalledAppWidgets(widgets); mWidgets.addAll(shortcuts); Collections.sort(mWidgets, new LauncherModel.WidgetAndShortcutNameComparator(mPackageManager)); updatePageCounts(); invalidateOnDataChange(); }
From source file:com.xabber.android.ui.activity.ContactList.java
@Override public void onContactClick(AbstractContact abstractContact) { if (action == null) { startActivity(ChatViewer.createSpecificChatIntent(this, abstractContact.getAccount(), abstractContact.getUser())); return;/*from w ww. j av a2 s . c om*/ } switch (action) { case ACTION_ROOM_INVITE: { action = null; Intent intent = getIntent(); String account = getRoomInviteAccount(intent); String user = getRoomInviteUser(intent); if (account != null && user != null) { try { MUCManager.getInstance().invite(account, user, abstractContact.getUser()); } catch (NetworkException e) { Application.getInstance().onError(e); } } finish(); break; } case Intent.ACTION_SEND: action = null; startActivity(ChatViewer.createSendIntent(this, abstractContact.getAccount(), abstractContact.getUser(), sendText)); finish(); break; case Intent.ACTION_CREATE_SHORTCUT: { createShortcut(abstractContact); finish(); break; } default: startActivity(ChatViewer.createSpecificChatIntent(this, abstractContact.getAccount(), abstractContact.getUser())); break; } }
From source file:com.xabber.android.ui.activity.ContactListActivity.java
@Override public void onContactClick(AbstractContact abstractContact) { if (action == null) { startActivity(ChatActivity.createSpecificChatIntent(this, abstractContact.getAccount(), abstractContact.getUser())); return;//w w w. ja va 2 s . c o m } switch (action) { case ACTION_ROOM_INVITE: { action = null; Intent intent = getIntent(); AccountJid account = getRoomInviteAccount(intent); UserJid user = getRoomInviteUser(intent); if (account != null && user != null) { try { MUCManager.getInstance().invite(account, user.getJid().asEntityBareJidIfPossible(), abstractContact.getUser()); } catch (NetworkException e) { Application.getInstance().onError(e); } } finish(); break; } case Intent.ACTION_SEND: action = null; startActivity(ChatActivity.createSendIntent(this, abstractContact.getAccount(), abstractContact.getUser(), sendText)); finish(); break; case Intent.ACTION_CREATE_SHORTCUT: { createShortcut(abstractContact); finish(); break; } default: startActivity(ChatActivity.createSpecificChatIntent(this, abstractContact.getAccount(), abstractContact.getUser())); break; } }
From source file:com.landenlabs.all_devtool.PackageFragment.java
/** * Load packages which are default (associated) with specific mime types. * * Use "adb shell dumpsys package r" to get full list *//*from ww w. jav a2 s. co m*/ void loadDefaultPackages() { m_workList = new ArrayList<PackingItem>(); String[] actions = { Intent.ACTION_SEND, Intent.ACTION_SEND, Intent.ACTION_SEND, Intent.ACTION_SEND, Intent.ACTION_VIEW, Intent.ACTION_VIEW, Intent.ACTION_VIEW, Intent.ACTION_VIEW, Intent.ACTION_VIEW, Intent.ACTION_VIEW, Intent.ACTION_VIEW, Intent.ACTION_VIEW, MediaStore.ACTION_IMAGE_CAPTURE, MediaStore.ACTION_VIDEO_CAPTURE, Intent.ACTION_CREATE_SHORTCUT }; String[] types = { "audio/*", "video/*", "image/*", "text/plain", "application/pdf", "application/zip", "audio/*", "video/*", "image/*", "text/html", "text/plain", "text/csv", "image/png", "video/*", "" }; long orderCnt = 1; for (int idx = 0; idx != actions.length; idx++) { String type = types[idx]; Intent resolveIntent = new Intent(actions[idx]); if (!TextUtils.isEmpty(type)) { if (type.startsWith("audio/*")) { Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1"); resolveIntent.setDataAndType(uri, type); } else if (type.startsWith("video/*")) { Uri uri = Uri.withAppendedPath(MediaStore.Video.Media.INTERNAL_CONTENT_URI, "1"); resolveIntent.setDataAndType(uri, type); } else if (type.startsWith("text/")) { Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()); resolveIntent.setDataAndType(uri, type); } else { resolveIntent.setType(type); } } PackageManager pm = getActivity().getPackageManager(); // PackageManager.GET_RESOLVED_FILTER); // or PackageManager.MATCH_DEFAULT_ONLY List<ResolveInfo> resolveList = pm.queryIntentActivities(resolveIntent, -1); // PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_INTENT_FILTERS); if (resolveList != null) { String actType = type = Utils.last(actions[idx].split("[.]")) + ":" + type; for (ResolveInfo resolveInfo : resolveList) { ArrayListPairString pkgList = new ArrayListPairString(); String appName = resolveInfo.activityInfo.loadLabel(pm).toString().trim(); addList(pkgList, "Type", actType); String pkgName = resolveInfo.activityInfo.packageName; PackageInfo packInfo = null; try { packInfo = pm.getPackageInfo(pkgName, 0); addList(pkgList, "Version", packInfo.versionName); addList(pkgList, "VerCode", String.valueOf(packInfo.versionCode)); addList(pkgList, "TargetSDK", String.valueOf(packInfo.applicationInfo.targetSdkVersion)); m_date.setTime(packInfo.firstInstallTime); addList(pkgList, "Install First", s_timeFormat.format(m_date)); m_date.setTime(packInfo.lastUpdateTime); addList(pkgList, "Install Last", s_timeFormat.format(m_date)); if (resolveInfo.filter != null) { if (resolveInfo.filter.countDataSchemes() > 0) { addList(pkgList, "Intent Scheme", ""); for (int sIdx = 0; sIdx != resolveInfo.filter.countDataSchemes(); sIdx++) addList(pkgList, " ", resolveInfo.filter.getDataScheme(sIdx)); } if (resolveInfo.filter.countActions() > 0) { addList(pkgList, "Intent Action", ""); for (int aIdx = 0; aIdx != resolveInfo.filter.countActions(); aIdx++) addList(pkgList, " ", resolveInfo.filter.getAction(aIdx)); } if (resolveInfo.filter.countCategories() > 0) { addList(pkgList, "Intent Category", ""); for (int cIdx = 0; cIdx != resolveInfo.filter.countCategories(); cIdx++) addList(pkgList, " ", resolveInfo.filter.getCategory(cIdx)); } if (resolveInfo.filter.countDataTypes() > 0) { addList(pkgList, "Intent DataType", ""); for (int dIdx = 0; dIdx != resolveInfo.filter.countDataTypes(); dIdx++) addList(pkgList, " ", resolveInfo.filter.getDataType(dIdx)); } } m_workList.add( new PackingItem(pkgName.trim(), pkgList, packInfo, orderCnt++, appName, actType)); } catch (Exception ex) { } } } if (false) { // TODO - look into this method, see loadCachedPackages int flags = PackageManager.GET_PROVIDERS; List<PackageInfo> packList = pm.getPreferredPackages(flags); if (packList != null) { for (int pkgIdx = 0; pkgIdx < packList.size(); pkgIdx++) { PackageInfo packInfo = packList.get(pkgIdx); // if (((packInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) == showSys) { addPackageInfo(packInfo); // } } } } } // getPreferredAppInfo(); /* List<ProviderInfo> providerList = getActivity().getPackageManager().queryContentProviders(null, 0, 0); if (providerList != null) { for (ProviderInfo providerInfo : providerList) { String name = providerInfo.name; String pkg = providerInfo.packageName; } } */ }