应用场景:用于安卓的短信发送功能

异常名称:Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND }

源码如下:

package com.phone.app.phone;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.EditText; import java.util.ArrayList; public class SmsActivity extends AppCompatActivity implements View.OnClickListener{     private  EditText edit = null;
    private  EditText smsEdit = null;     @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sms);         edit = (EditText) findViewById(R.id.edit);//获取文本的对象
        smsEdit = (EditText) findViewById(R.id.sms);//获取文本的对象
//        Button btn = (Button) findViewById(R.id.btn);//获取按钮的对象
//
//        //添加按钮事件监听器
//        btn.setOnClickListener(this);
    }      public void onClick(View view){//定义事件对应处理的方法          String num = edit.getText().toString();//获取文本框中的电话号码
         String smstext = smsEdit.getText().toString();
         Intent intent = new Intent();//创建一个意图          SmsManager sm = SmsManager.getDefault();
         intent.setAction(intent.ACTION_SEND);//设置意图的动作
         intent.setClassName("com.phone.app.phone","com.phone.app.phone.SmsActivity");//设置处理intent的activity
         ArrayList<String> list = sm.divideMessage(smstext);  //因为一条短信有字数限制,因此要将长短信拆分
         for(String text:list){
             sm.sendTextMessage(num, null, text, null, null);
         }          //intent.setData(Uri.parse("tel:"+num));//设置意图的数据
         this.startActivity(intent);//使用意图开启一个界面
     }
}

解决方案:

设置处理intent的activity ,

intent.setClassName("com.phone.app.phone","com.phone.app.phone.SmsActivity");//设置处理intent的activity

即可解决此bug!

bug-android之ActivityNotFoundException的更多相关文章

  1. 【Android 疑难杂症1】android.content.ActivityNotFoundException: Unable to find explicit activity class

    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.cnote ...

  2. android.content.ActivityNotFoundException: Unable to find explicit activity class have you declared this activity in your AndroidManifest.xml?

    在整合PullToRefresh的时候出现如下异常 10-22 23:20:01.826 32331-32331/com.example.news.andoridnewsapp E/AndroidRu ...

  3. (转载)Android学习笔记⑨——android.content.ActivityNotFoundException异常处理

    异常1:Java.lang.ClassNotFoundException 08-13 18:29:22.924: E/AndroidRuntime(1875):Caused by: Java.lang ...

  4. bug -- android 7.0 popwindow显示位置异常情况解决

    android 7.0 popwindow显示位置异常,在android7.1官方进行解决了,但是还是要多7.0的bug进行解决,我的解决方案里面通过重写popwindow进行适配: import a ...

  5. [bug]android monkey命令在Android N和Android O上的一点差异发现

    最近再调试这个统计FPS的代码,发现代码在android N上可以正常运行,但在android O上却运行不了,拼了命的报错,给出的提示就是 ZeroDivisionError: division b ...

  6. android.content.ActivityNotFoundException: No Activity found to handle Intent { (has extras) }

    报错: 初始代码: @OnClick(R.id.include_top_iv_more) public void onViewClicked() { Intent intent_chat_set = ...

  7. [技术博客]Android 开发 Bug Log

    [技术博客] Android 开发 Bug Log 大大小小的bug,聪明的愚蠢的都有, 持续记录中...... java.lang.IllegalArgumentException: The sty ...

  8. Android之“Unfortunately,xxx has stopped!”

    初学Android遇到Unfortunately,xxx has stopped!真是一件让人头疼的事情,下面就遇到的两种可能情况给出解决方案.通常遇到的情况在于由一个Activity跳转至另一个Ac ...

  9. Android(java)学习笔记99:android的短信发送器研究

    1.第一种可以调用系统内部的短信程序. 之前我曾经出现过一个bug就是报错: android.content.ActivityNotFoundException: No Activity found ...

随机推荐

  1. Java适配器设计模式

    适配器设计模式,一个接口首先被一个抽象类先实现(此抽象类通常称为适配器类),并在此抽象类中实现若干方法(但是这个抽象类中的方法体是空的),则以后的子类直接继承此抽象类,就可以有选择地覆写所需要的方法. ...

  2. 通过Ajax方式上传文件,使用FormData进行Ajax请求

    通过传统的form表单提交的方式上传文件: <form id= "uploadForm" action= "http://localhost:8080/cfJAX_ ...

  3. clipboard复制剪贴板功能,以及用requirejs时报错---Uncaught ReferenceError: Clipboard is not defined

    zeroclipboard是走的flash插件,手机浏览器是不支持的,所以不得不舍弃之,用clipboard,clipboard不需要flash就可以完成复制剪切等功能,而且可以兼容pc,移动端,下面 ...

  4. LeetCode —— Merge k Sorted Lists

    /* ** 算法的思路: ** 1.将k个链表的首元素进行建堆 ** 2.从堆中取出最小的元素,放到链表中 ** 3.如果取出元素的有后续的元素,则放入堆中,若没有则转步骤2,直到堆为空 */ #in ...

  5. yii2接收activeform表单信息

    第一种方法: $model->load(Yii::$app->request->post()); 第二种方法: 获取具体的某一项的值 $demo = $_POST['模型名']['字 ...

  6. yii2 如何用命名空间方式使用第三方类库

    原文地址:http://www.yiichina.com/tutorial/395 Yii 2.0最显著的特征之一就是引入了命名空间,因此对于自定义类的引入方式也同之前有所不同.这篇文章讨论一下如何利 ...

  7. 15分钟学会使用Git和远程代码库

    git是个了不起但却复杂的源代码管理系统.它能支持复杂的任务,却因此经常被认为太过复杂而不适用于简单的日常工作.让我们诚实一记吧:Git是复杂的,我们不要装作它不是.但我仍然会试图教会你用(我的)基本 ...

  8. css外边距合并和z-index的问题

    参考这篇文章, 将外边距的 折叠 参考这篇文章, 将bfc的生成, bfc的应用 参考这篇文章 position: absolute的元素, 仍然具有内填充padding和border边框属性样式, ...

  9. .ssh/config简单使用

    转自:http://blog.lizhigang.net/archives/265 .ssh/config简单使用 需求:  工作的电脑经常会存储不同的key,并且使用不同的用户登录linux系统.如 ...

  10. Memcached基础知识

    主要内容: Memcached基本的工作原理 Memcached的两阶段哈希 Memcached的数据存储方式 Memcached新建Item分配内存过程 Memcached的数据过期方式 Memca ...