List of usage examples for android.content.pm PackageManager queryIntentActivities
public abstract List<ResolveInfo> queryIntentActivities(Intent intent, @ResolveInfoFlags int flags);
From source file:th.in.ffc.app.FFCFragmentActivity.java
@Override public void startActivityForResult(Intent intent, int requestCode) { intent.putExtra(EXTRA_PCUCODE, this.extra_pcucode); intent.putExtra(EXTRA_USER, this.extra_user); PackageManager pm = getPackageManager(); List<ResolveInfo> IntentList = pm.queryIntentActivities(intent, 0); if (IntentList.size() == 0) { Toast.makeText(this, "Not Found Activity!", Toast.LENGTH_SHORT).show(); } else {//from w w w. ja v a2s. com super.startActivityForResult(intent, requestCode); overridePendingTransition(R.anim.slide_in, R.anim.slide_out); } }
From source file:com.ntsync.android.sync.activities.ImportActivity.java
private void initStartContactBtn() { Button startBtn = (Button) findViewById(R.id.startContactApp); PackageManager packageManager = getPackageManager(); Intent contactAppIntent = ContactManager.createContactAppIntent(); boolean isIntentSafe = false; if (contactAppIntent != null) { List<ResolveInfo> activities = packageManager.queryIntentActivities(contactAppIntent, 0); isIntentSafe = !activities.isEmpty(); Drawable icon = ContactManager.getContactAppIcon(this, contactAppIntent); startBtn.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); }//w ww . j a va 2 s.com startBtn.setEnabled(isIntentSafe); }
From source file:aerizostudios.com.cropshop.MainActivity.java
public void like_facebook(View v) { final String urlFb = "fb://page/" + "430860500445507"; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(urlFb));//from ww w . j av a 2 s .co m // If a Facebook app is installed, use it. Otherwise, launch // a browser final PackageManager packageManager = getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() == 0) { final String urlBrowser = "https://www.facebook.com/" + "cropshopofficial"; intent.setData(Uri.parse(urlBrowser)); } startActivity(intent); }
From source file:com.launcher.silverfish.LauncherActivity.java
private void autoSortApplications() { // Set up both SQL helper and package manager LauncherSQLiteHelper sql = new LauncherSQLiteHelper(this.getBaseContext()); PackageManager mPacMan = getApplicationContext().getPackageManager(); // Set MAIN and LAUNCHER filters, so we only get activities with that defined on their manifest Intent i = new Intent(Intent.ACTION_MAIN, null); i.addCategory(Intent.CATEGORY_LAUNCHER); // Get all activities that have those filters List<ResolveInfo> availableActivities = mPacMan.queryIntentActivities(i, 0); // Store here the packages and their categories IDs // This will allow us to add all the apps at once instead opening the database over and over HashMap<String, Integer> pkg_categoryId = PackagesCategories.setCategories(getApplicationContext(), availableActivities);// ww w . j a v a 2 s .co m // Then add all the apps to their corresponding tabs at once sql.addAppsToTab(pkg_categoryId); }
From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java
/** * If email apps are available.//w w w . j a v a 2 s . c o m * * @param ctx * The application context. * @return * true if available, otherwise false */ private boolean isEmailAccountConfigured(Context ctx) { Uri uri = Uri.fromParts("mailto", "max@mustermann.com", null); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); PackageManager pm = ctx.getPackageManager(); int apps = pm.queryIntentActivities(intent, 0).size(); if (apps == 0) { return false; } AccountManager am = AccountManager.get(ctx); int accounts; try { accounts = am.getAccounts().length; } catch (Exception e) { Log.e("EmailComposer", "Missing GET_ACCOUNTS permission."); return true; } return accounts > 0; }
From source file:com.bangalore.barcamp.activity.ShareActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.share_screen); mDrawerToggle = BCBFragmentUtils.setupActionBar(this, "Share"); // BCBUtils.createActionBarOnActivity(this); // BCBUtils.addNavigationActions(this); ((EditText) findViewById(R.id.editText1)).addTextChangedListener(new TextWatcher() { @Override/*from ww w . ja va 2 s .co m*/ public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { ((TextView) findViewById(R.id.charsLeftTextView)).setText("Chars left: " + (140 - s.length() - 7)); } }); if (getIntent().hasExtra(SHARE_STRING)) { ((EditText) findViewById(R.id.editText1)).setText(getIntent().getStringExtra(SHARE_STRING)); } Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); final PackageManager pm = getPackageManager(); final Spinner spinner = (Spinner) findViewById(R.id.shareTypeSpinner); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 0); String selectedItem = BCBSharedPrefUtils.getShareSettings(getApplicationContext()); int selectedPos = -1; for (ResolveInfo info : matches) { adapter.add(info.loadLabel(pm)); if (selectedItem.equals(info.loadLabel(pm))) { selectedPos = matches.indexOf(info); } } spinner.setAdapter(adapter); if (selectedPos != -1) { spinner.setSelected(true); spinner.setSelection(selectedPos); } ((TextView) findViewById(R.id.charsLeftTextView)).setText("Chars left: 140"); ((Button) findViewById(R.id.button1)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); int appSelectedPos = spinner.getSelectedItemPosition(); ResolveInfo info = matches.get(appSelectedPos); intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); BCBSharedPrefUtils.setShareSettings(getApplicationContext(), (String) info.loadLabel(pm)); intent.putExtra(Intent.EXTRA_TEXT, ((EditText) findViewById(R.id.editText1)).getText().toString() + " #barcampblr"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); } }); BCBFragmentUtils.addNavigationActions(this); supportInvalidateOptionsMenu(); Tracker t = ((BarcampBangalore) getApplication()).getTracker(); // Set screen name. t.setScreenName(this.getClass().getName()); // Send a screen view. t.send(new HitBuilders.AppViewBuilder().build()); }
From source file:com.max2idea.android.fwknop.Fwknop.java
private void startApp() { Intent i = new Intent(Intent.ACTION_RUN); i.setComponent(new ComponentName("org.connectbot", "org.connectbot.HostListActivity")); PackageManager p = this.getPackageManager(); List list = p.queryIntentActivities(i, p.COMPONENT_ENABLED_STATE_DEFAULT); if (list.isEmpty()) { Log.v("SPA", "ConnectBot is not installed"); Toast.makeText(this, "ConnectBot is not installed", Toast.LENGTH_LONG).show(); } else {/*w w w.java2 s.c o m*/ Log.v("SPA", "Starting connectBot"); Toast.makeText(this, "Starting ConnectBot", Toast.LENGTH_LONG); startActivity(i); } }
From source file:com.glabs.homegenie.util.VoiceControl.java
public VoiceControl(StartActivity hgactivity) { _hgcontext = hgactivity;//from ww w . j a va 2 s . co m //find out whether speech recognition is supported PackageManager packManager = _hgcontext.getPackageManager(); List<ResolveInfo> intActivities = packManager .queryIntentActivities(new Intent(RecognizerIntent.ACTION_WEB_SEARCH), 0); if (intActivities.size() != 0) { // TODO ok speech recognition supported } else { //speech recognition not supported, disable button and output message Toast.makeText(_hgcontext, "Oops - Speech recognition not supported!", Toast.LENGTH_LONG).show(); } _lingodata = new LingoData(); new RetrieveLingoDataTask().execute(); }
From source file:com.launcher.silverfish.launcher.LauncherActivity.java
private void autoSortApplications() { // Set up both SQL helper and package manager LauncherSQLiteHelper sql = new LauncherSQLiteHelper((App) getApplication()); PackageManager mPacMan = getApplicationContext().getPackageManager(); // Set MAIN and LAUNCHER filters, so we only get activities with that defined on their manifest Intent i = new Intent(Intent.ACTION_MAIN, null); i.addCategory(Intent.CATEGORY_LAUNCHER); // Get all activities that have those filters List<ResolveInfo> availableActivities = mPacMan.queryIntentActivities(i, 0); // Store here the packages and their categories IDs // This will allow us to add all the apps at once instead opening the database over and over HashMap<String, Long> pkg_categoryId = PackagesCategories.setCategories(getApplicationContext(), availableActivities);//from w w w. j a v a2 s . com // Then add all the apps to their corresponding tabs at once sql.addAppsToTab(pkg_categoryId); }
From source file:edu.cmu.cylab.starslinger.view.ComposeFragment.java
@SuppressWarnings("deprecation") private void drawFileImage() { String filenameArray[] = mFilePath.split("\\."); String extension = filenameArray[filenameArray.length - 1]; String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mThumb != null && mThumb.length > 0) { ByteArrayInputStream in = new ByteArrayInputStream(mThumb); BitmapDrawable tn = new BitmapDrawable(in); mImageViewFile.setImageDrawable(tn); } else {// w w w . ja v a 2 s . com Intent viewIntent = new Intent(Intent.ACTION_VIEW); viewIntent.setType(mime); PackageManager pm = getActivity().getPackageManager(); List<ResolveInfo> lract = pm.queryIntentActivities(viewIntent, PackageManager.MATCH_DEFAULT_ONLY); boolean resolved = false; for (ResolveInfo ri : lract) { if (!resolved) { try { Drawable icon = pm.getApplicationIcon(ri.activityInfo.packageName); mImageViewFile.setImageDrawable(icon); resolved = true; } catch (NameNotFoundException e) { mImageViewFile.setImageDrawable(getResources().getDrawable(R.drawable.ic_menu_file)); } } } } }