Thursday, November 3, 2011

No applications can perform this action - Check Intent available and force to install

In the article "Send email using Intent.ACTION_SEND", we startActivity with intent of Intent.ACTION_SEND. I assume all Android should have gmail, or Composer, installed. But somebody complain with error of "No applications can perform this action".

We can check if any package installed to handle the intent in advance by calling queryIntentActivities(). If the returned list not ">0" (no aplications installed), open Market to install "market://details?id=com.google.android.gm".

Open Market if No applications can perform this action

Such a approach can be applied to other intent.

package com.exercise.AndroidEMail;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AndroidEMail extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

final EditText edittextEmailAddress = (EditText)findViewById(R.id.email_address);
final EditText edittextEmailSubject = (EditText)findViewById(R.id.email_subject);
final EditText edittextEmailText = (EditText)findViewById(R.id.email_text);
Button buttonSendEmail_intent = (Button)findViewById(R.id.sendemail_intent);

//Preset default
edittextEmailText.setText("email body");

buttonSendEmail_intent.setOnClickListener(new Button.OnClickListener(){

public void onClick(View arg0) {
// TODO Auto-generated method stub

String emailAddress = edittextEmailAddress.getText().toString();
String emailSubject = edittextEmailSubject.getText().toString();
String emailText = edittextEmailText.getText().toString();

String emailAddressList[] = {emailAddress};

Intent intent = new Intent(Intent.ACTION_SEND);

intent.putExtra(Intent.EXTRA_EMAIL, emailAddressList);
intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
intent.putExtra(Intent.EXTRA_TEXT, emailText);

//Check if Intent available
List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() >0 ){
startActivity(Intent.createChooser(intent, "Choice App to send email:"));
//Start Market to downoad and install gmail
Uri uri = Uri.parse("market://details?id=com.google.android.gm");
Intent it = new Intent(Intent.ACTION_VIEW, uri);


The layout, main.xml, refer to the article "Send email using Intent.ACTION_SEND".

Download the files.


Thank you for reading this article No applications can perform this action - Check Intent available and force to install With URL http://x-tutorials.blogspot.com/2011/11/no-applications-can-perform-this-action.html. Also a time to read the other articles.


Write your comment for this article No applications can perform this action - Check Intent available and force to install above!