user3466400
user3466400

Reputation: 41

No Activity found to handle Intent errors

I am getting the following error in LogCat when running my application. The error occurs when pressing button3, the callButton. This tries to bring up a list of contacts to call. It does nothing and after a few more presses the app crashes.

Here is the code. I understand it is quite confusing, I am following a beginner android dev.

I include the manifest file here; http://pastebin.com/H6hw7i89

package com.example.contactpicker;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.content.ContentUris;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Contacts.Intents;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract;
import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ContactPickerTester extends Activity {

    public static final int PICK_CONTACT = 1;


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_contact_picker_tester);

        Button button = (Button) findViewById(R.id.button1);


        button.setOnClickListener(new OnClickListener() {


            public void onClick(View _view) {
                Intent intent = new Intent(Intent.ACTION_PICK, Uri
                            .parse("content://contacts/"));
                startActivityForResult(intent, PICK_CONTACT);
            }
        });


        Button insertContactButton = (Button) findViewById(R.id.button2);
        insertContactButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                insertContactWithIntent();
            }
        });
    }


    private void insertContactWithIntent() {
        //inserting a new contact using intents//
        Intent intent = new Intent(Intent.ACTION_INSERT,
                ContactsContract.Contacts.CONTENT_URI);
        startActivity(intent);



 Button callButton = (Button) findViewById(R.id.button3);

 callButton.setOnClickListener(new OnClickListener() {
     @Override
     public void onClick(View v){
         Intent myIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("content://contacts/"));
         startActivity(myIntent);
     }
 });
 }
    @Override
    public void onActivityResult(int reqCode, int resCode, Intent data) {
        super.onActivityResult(reqCode, resCode, data);

        switch (reqCode) {
        case (PICK_CONTACT): {
            if (resCode == Activity.RESULT_OK) {
                Uri contactData = data.getData();
                Cursor c = managedQuery(contactData, null, null, null, null);
                c.moveToFirst();
                String name = c
                        .getString(c
                                .getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
                TextView tv = (TextView) findViewById(R.id.selected_contact_textview);
                tv.setText(name);
            }
            break;
        }
        }
    }
}

Upvotes: 0

Views: 164

Answers (1)

Pete
Pete

Reputation: 4051

I had this same issue. When I declared the Intent like this:

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT_REQUEST);

The problem was solved

Upvotes: 1

Related Questions