我正在使用污染清单数据库应用程序,当我单击呼叫应用程序正在工作时,但是当我单击列表中的发送电子邮件时,出现以下错误:

    FATAL EXCEPTION: main
android.content.ActivityNotFoundException: No Activity found to handle Intent {     act=android.intent.action.SEND typ=plain/text (has extras) }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
at android.app.Activity.startActivityForResult(Activity.java:2827)
at android.app.Activity.startActivity(Activity.java:2933)
at org.example.dbcontactconsole.Detalii.onListItemClick(Detalii.java:75)
at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3513)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)


我的类Detalii.java:package org.example.dbcontactconsole;

     import java.util.ArrayList;
    import java.util.List;

    import android.app.ListActivity;
    import android.content.Intent;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.net.Uri;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;
     import android.widget.TextView;

   public class Detalii extends ListActivity
   {
   protected TextView contactName;
   protected TextView contactPhone;
   protected TextView email;
   protected int contactId;
   protected  List<Actiune> actiune;
   protected ActiuneAdapter adapter;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.detalii);

     contactId = getIntent().getIntExtra("Contact_ID",0);
    SQLiteDatabase db = (new DbCreate(this)).getWritableDatabase();
    Cursor cursor = db.rawQuery("SELECT name,phone,email FROM contactTest1 WHERE _id=?",new    String[]{""+contactId});

    if (cursor.getCount() == 1)
    {
    cursor.moveToFirst();

    contactName = (TextView) findViewById(R.id.name);
    contactName.setText(cursor.getString(cursor.getColumnIndex("name")));

   actiune= new ArrayList<Actiune>();
   String phoneString=cursor.getString(cursor.getColumnIndex("phone"));
   if (phoneString!=null)
   {
    actiune.add(new Actiune("Suna la numar",phoneString,Actiune.ACTION_CALL));
    }
   String stringemail = cursor.getString(cursor.getColumnIndex("email"));
   if (stringemail != null) {
           actiune.add(new Actiune("Email", stringemail,Actiune.ACTION_EMAIL));
           }
   adapter = new ActiuneAdapter();
   setListAdapter(adapter);
      }
     }
    public void onListItemClick(ListView parent, View view, int position, long id) {

    Actiune action = actiune.get(position);

     Intent intent;
     switch (action.getType()) {

    case Actiune.ACTION_CALL:
            Uri callUri = Uri.parse("tel:" + action.getData());
            intent = new Intent(Intent.ACTION_CALL, callUri);
        startActivity(intent);
            break;

    case Actiune.ACTION_EMAIL:
    intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/text");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{action.getData()});
    startActivity(intent);
    break;


     }
     }

    class ActiuneAdapter extends ArrayAdapter<Actiune> {

     ActiuneAdapter() {
            super(Detalii.this, R.layout.actiune_detalii, actiune);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    Actiune action = actiune.get(position);
    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.actiune_detalii, parent, false);
    TextView label = (TextView) view.findViewById(R.id.label);
    label.setText(action.getLabel());
    TextView data = (TextView) view.findViewById(R.id.data);
    data.setText(action.getData());
    return view;
     }

     }

     }


`
这是我的MAnifest.xml:

     <?xml version="1.0" encoding="utf-8"?>
   <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="org.example.dbcontactconsole"
  android:versionCode="1"
  android:versionName="1.0">
<uses-permission android:name="android.permission.CALL_PHONE" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".DbContactConsole"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".ContactDetails"
        android:label="@string/contact_intent"
        android:theme="@android:style/Theme.Dialog">
    </activity>

         <activity android:name=".Search"
        android:label="@string/contact_in"
        android:theme="@android:style/Theme.Dialog">
       </activity>
          <activity android:name=".Detalii"
        android:label="@string/contact_int"
        android:theme="@android:style/Theme.Dialog">
    </activity>

   </application>
   <uses-sdk android:minSdkVersion="8" />

最佳答案

在清单中添加一个uses-permissions android.permission.CALL_PHONE。也可能看到:

http://www.helloandroid.com/tutorials/how-make-phone-call-your-application

http://www.helloandroid.com/tutorials/how-send-email-your-application

10-08 14:57