List of usage examples for android.content.pm PackageManager queryIntentActivities
public abstract List<ResolveInfo> queryIntentActivities(Intent intent, @ResolveInfoFlags int flags);
From source file:lewa.support.v7.app.ActionBarActivityDelegateBase.java
private List<String> getHomes() { List<String> names = new ArrayList<String>(); try {/*from w ww . j a va 2 s . co m*/ PackageManager packageManager = mActivity.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo ri : resolveInfo) { names.add(ri.activityInfo.packageName); System.out.println(ri.activityInfo.packageName); } } catch (Exception e) { } return names; }
From source file:conversandroid.SimpleASR.java
/** * Sets up the listener for the button that the user * must click to start talking/*from w w w .j a v a2 s .c o m*/ */ @SuppressLint("DefaultLocale") private void setSpeakButton() { //Gain reference to speak button Button speak = (Button) findViewById(R.id.speech_btn); final PackageManager packM = getPackageManager(); //Set up click listener speak.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Speech recognition does not currently work on simulated devices, //it the user is attempting to run the app in a simulated device //they will get a Toast if ("generic".equals(Build.BRAND.toLowerCase())) { Toast toast = Toast.makeText(getApplicationContext(), "ASR is not supported on virtual devices", Toast.LENGTH_SHORT); toast.show(); Log.d(LOGTAG, "ASR attempt on virtual device"); } else { // find out whether speech recognition is supported List<ResolveInfo> intActivities = packM .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (intActivities.size() != 0) { setRecognitionParams(); //Read speech recognition parameters from GUI listen(); //Set up the recognizer with the parameters and start listening } else { Toast toast = Toast.makeText(getApplicationContext(), "ASR not supported", Toast.LENGTH_SHORT); toast.show(); Log.d(LOGTAG, "ASR not supported"); } } } }); }
From source file:com.ibuildapp.romanblack.CataloguePlugin.ProductDetails.java
/** * Finds the best email client to share via email. * * @return prepared intent//from ww w. j a v a 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:org.mozilla.gecko.GeckoAppShell.java
private static Drawable getDrawableForExtension(PackageManager pm, String aExt) { Intent intent = new Intent(Intent.ACTION_VIEW); MimeTypeMap mtm = MimeTypeMap.getSingleton(); String mimeType = mtm.getMimeTypeFromExtension(aExt); if (mimeType != null && mimeType.length() > 0) intent.setType(mimeType);//from ww w . j a v a 2 s.c om else return null; List<ResolveInfo> list = pm.queryIntentActivities(intent, 0); if (list.size() == 0) return null; ResolveInfo resolveInfo = list.get(0); if (resolveInfo == null) return null; ActivityInfo activityInfo = resolveInfo.activityInfo; return activityInfo.loadIcon(pm); }
From source file:uk.co.droidinactu.ebooklauncher.EBookLauncherActivity.java
private void updateButtonCounts() { new Thread() { @Override/*from w ww .ja va 2s .co m*/ public void run() { setName("updateButtonCounts()"); Cursor tmpCursor = myApp.dataMdl.getBooks(EBookLauncherActivity.this.getApplication(), "", BookSortBy.TITLE, ""); if (tmpCursor != null) { btnBooksCount = tmpCursor.getCount(); tmpCursor.close(); } tmpCursor = myApp.dataMdl.getCollections(0, 999, null); if (tmpCursor != null) { btnCollectionsCount = tmpCursor.getCount(); tmpCursor.close(); } tmpCursor = myApp.dataMdl.getPeriodicals(EBookLauncherActivity.this.getApplication()); if (tmpCursor != null) { btnPeriodicalsCount = tmpCursor.getCount(); tmpCursor.close(); } final PackageManager manager = EBookLauncherActivity.this.getPackageManager(); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { btnApps.setText(String.format( EBookLauncherActivity.this.getResources().getString(R.string.page1_Apps), apps.size())); btnBooks.setText(String.format( EBookLauncherActivity.this.getResources().getString(R.string.page1_Books), btnBooksCount)); btnCollections.setText(String.format( EBookLauncherActivity.this.getResources().getString(R.string.page1_Collections), btnCollectionsCount)); btnPeriodicals.setText(String.format( EBookLauncherActivity.this.getResources().getString(R.string.page1_Periodicals), btnPeriodicalsCount)); } }); } }.start(); }
From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java
public void checkVoiceRecognition() { // Check if voice recognition is present PackageManager pm = getPackageManager(); List<ResolveInfo> activities = pm .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (activities.size() != 0) { mVoiceRecognitionEnabled = true; }/*from www.ja va 2s. c o m*/ }
From source file:me.willowcheng.makerthings.ui.OpenHABMainActivity.java
public void checkVoiceRecognition() { // Check if voice recognition is present PackageManager pm = getPackageManager(); List<ResolveInfo> activities = pm .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (activities.size() == 0) { // speakButton.setEnabled(false); // speakButton.setText("Voice recognizer not present"); Toast.makeText(this, "Voice recognizer not present, voice recognition disabled", Toast.LENGTH_SHORT) .show();//from w w w . j a v a 2 s.c o m } else { mVoiceRecognitionEnabled = true; } }
From source file:com.tct.email.NotificationController.java
public boolean isIntentExisting(Context context, String action) { final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(action); List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_ALL); return resolveInfo.size() > 0; }
From source file:com.android.dialer.DialtactsActivity.java
private boolean canIntentBeHandled(Intent intent) { final PackageManager packageManager = getPackageManager(); final List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo != null && resolveInfo.size() > 0; }
From source file:indrora.atomic.activity.ConversationActivity.java
/** * On resume/*from w w w . j a v a 2 s . c o m*/ */ @Override public void onResume() { // register the receivers as early as possible, otherwise we may loose a // broadcast message channelReceiver = new ConversationReceiver(server.getId(), this); registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_MESSAGE)); registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_NEW)); registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_REMOVE)); registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_TOPIC)); serverReceiver = new ServerReceiver(this); registerReceiver(serverReceiver, new IntentFilter(Broadcast.SERVER_UPDATE)); super.onResume(); // Check if speech recognition is enabled and available if (new Settings(this).isVoiceRecognitionEnabled()) { PackageManager pm = getPackageManager(); Button speechButton = (Button) findViewById(R.id.speech); List<ResolveInfo> activities = pm .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (activities.size() != 0) { ((Button) findViewById(R.id.speech)).setOnClickListener(new SpeechClickListener(this)); speechButton.setVisibility(View.VISIBLE); } } // Start service Intent intent = new Intent(this, IRCService.class); intent.setAction(IRCService.ACTION_FOREGROUND); startService(intent); int flags = 0; if (android.os.Build.VERSION.SDK_INT > 13) { flags |= Context.BIND_ABOVE_CLIENT; flags |= Context.BIND_IMPORTANT; } bindService(intent, this, flags); // Let's be explicit about this. ((EditText) findViewById(R.id.input)).setEnabled(true); // Optimization - cache field lookup Collection<Conversation> mConversations = server.getConversations(); MessageListAdapter mAdapter; // Fill view with messages that have been buffered while paused for (Conversation conversation : mConversations) { String name = conversation.getName(); mAdapter = pagerAdapter.getItemAdapter(name); if (mAdapter != null) { mAdapter.addBulkMessages(conversation.getBuffer()); conversation.clearBuffer(); } else { // Was conversation created while we were paused? if (pagerAdapter.getPositionByName(name) == -1) { onNewConversation(name); } } // Clear new message notifications for the selected conversation if (conversation.getStatus() == Conversation.STATUS_SELECTED && conversation.getNewMentions() > 0) { Intent ackIntent = new Intent(this, IRCService.class); ackIntent.setAction(IRCService.ACTION_ACK_NEW_MENTIONS); ackIntent.putExtra(IRCService.EXTRA_ACK_SERVERID, serverId); ackIntent.putExtra(IRCService.EXTRA_ACK_CONVTITLE, name); startService(ackIntent); } } // Remove views for conversations that ended while we were paused int numViews = pagerAdapter.getCount(); if (numViews > mConversations.size()) { for (int i = 0; i < numViews; ++i) { if (!mConversations.contains(pagerAdapter.getItem(i))) { pagerAdapter.removeConversation(i--); --numViews; } } } // Join channel that has been selected in JoinActivity // (onActivityResult()) if (joinChannelBuffer != null) { new Thread() { @Override public void run() { binder.getService().getConnection(serverId).joinChannel(joinChannelBuffer); joinChannelBuffer = null; } }.start(); } setupColors(); setupIndicator(); openSoftKeyboard(findViewById(R.id.input)); server.setIsForeground(true); }