zoukankan      html  css  js  c++  java
  • Android发短信的应用—新手遇到的最常见问题

    昨天模仿写了一个发短信的应用程序,运行的时候,点击发送按钮,总是出现进程强制关闭的问题:






    很疑惑,不知道问题处在哪儿。查看Console,没有出现问题,也没有报错。
    开始我觉得是我这个模拟器路径的原因,这个模拟器是我很久以前就安装在D:\Program Files\Andriod  目录下面了。飞哥说安装目录中最好是不要有中文,不要有空格。我在网上查了一下,发现这个默认的安装路径是C:\Program Files,也是有空格的,所以理论上来说,不是安装目录的问题。
    继续在网上查找原因,发现了LogCat这个东西,虽然现在还不知道这个什么东西的,但是在这个里面能查看Android模拟器运行时系统的所有记录,点E,找到错误如下:

    图片
    这个好像是这个应用程序没有权限去发送短信。
    查了一下发短信的权限:<uses-permission android:name="android.permission.SEND_SMS" />。在manifest.xml中添加上。
    在运行,问题解决。 5554/5556之间可以自由发短信了。

    这是个超级小白的错误。总结一下:
    首先查看LogCat,查看原因,根据原因查看代码中的问题。
    在使用Android的东西的时候,一定得先注册权限,让他允许你使用。。。。。。

    附录:Android权限清单
    android.permission.ACCESS_CHECKIN_PROPERTIES :
    Allows read/write access to the “properties” table in the checkin database, to change values that get uploaded.
    允许以read/write访问检入数据库(checkin database?)的"properties"表,并且可以更改、更新数据库。
      
    android.permission.ACCESS_COARSE_LOCATION :
    Allows an application to access coarse(e.g, Cell-ID, WIFI) location.
    允许一个应用程序通过访问CellID和WiFi热点等方式获取粗略的本地位置。
      
    android.permission.ACCESS_FINE_LOCATION :
    Allows an application to access fine(e.g, GPS) location.
    允许一个应用程序通过访问GPS等方式获取较精确的本地位置。
      
    android.permission.ACCESS_LOCATION_EXTRA_COMMANDS :
    Allows an application to access extra location provider commands.
    允许一个应用程序访问(使用)额外的本地位置服务提供者。
      
    android.permission.ACCESS_MOCK_LOCATION :
    Allows an application to access mock location providers for testing.
    允许一个应用程序访问(创建)模拟的位置服务提供者用于测试。
      
    android.permission.ACCESS_NETWORK_STATE :
    Allows applications to access information about networks.
    允许应用程序访问(获取)网络信息。
      
    android.permission.ACCESS_SURFACE_FLINGER :
    Allows an application to use SurfaceFlinger’s low level features.
    允许一个应用程序使用SurfaceFlinger的底层属性。(什么是SurfaceFlinger?)
    android.permission.ACCESS_WIFI_STATE :
    Allows applications to access information about Wi-Fi networks.
    允许应用程序获取Wi-Fi网络的信息)。
      
    android.permission.ACCOUNT_MANAGER :
    Allows an applications to call into AccountAuthenticators.
    允许一个应用程序启动账户认证。
    android.permission.AUTHERTICATE_ACCOUTS :
    Allows an applicatons to act as an AccoutAuterticator for the AccoutManger.
    允许一个应用程序充当账户认证管理者。
    android.permission.BATTERY_STATS :
    Allows an application to collect battery statistics.
    允许一个应用程序获取电池使用的统计信息(剩余电量、电池的耗电情况(各主要应用程序耗电占总耗电的百分比等)等)。
    android.permission.BIND_APPWIGET :
    Allows an application to tell the AppWiget service which application can access AppWiget data.
    允许一个应用程序告知AppWiget服务:我(当前应用程序)可以访问AppWiget数据。
    android.permission.BIND_DEVICE_ADMIN :
    Must be required by device administration receiver, to ensure that only the system can interact with it.
    设备管理服务必须拥有的权限,确保只有系统可以通过设备管理服务与设备进行互动(访问设备,数据交互)。
    android.permission.BIND_INPUT_METHOD :
    Must be required by an InputMethodService, to ensure that only the system can bind to it.
    输入法服务(InputMethodService)必须拥有的权限,确保只有系统可以绑定之。
    android.permission.BIND_WALLPAPER : 
    Must be required by a WallpaperService, to ensure that only the system can bind to it.
    桌面服务(WallpaperService)必须拥有的权限,确保只有系统才可以绑定之.
    android.permission.BLUETOOTH :
    Allows applications to connect to paired buletooth devices.
    允许应用程序连接到已配对的蓝牙设备(远端蓝牙,非本机蓝牙)。
    android.permission.BULETOOTH_ADMIN : 
    Allows applications to discover an pair bluetooth devices.
    允许应用程序搜索并且配对蓝牙设备。
    android.permission.BRICK :
    Required to be able to disable the device (very dangrous!).
    禁用设备必须拥有的权限(危险,慎用!)。
    android.permission.BROADCAST_PACKAGE_REMOVED :
    Allows an application to boradcast a notification that an application package has been removed.
    允许一个应用程序广播“一个(不是同一个)应用程序包已经被移除”的通告。(指一个应用程序已被卸装的通告?)
    android.permission.BROADCAST_SMS : 
    Allows an application to broadcast an SMS receipt notification.
    允许一个应用程序广播一个短信回执(如:帅哥,你有一条新的短消息!)的通告。
    android.permission.BROADCAST_STICKY :
    Allows an application to broadcast sticky intents.
    允许一个应用程序广播常用(sticky?) intents.
    android.permission.WAP_PUSH :
    Allows an application to broadcast a WAP PUSH receipt notification.
    允许一个应用程序广播WAP PUSH回执通告。
    说明:WAP-PUSH,WAP推送短信,是一种特殊格式的短信。WAP-PUSH可以将某一站点或某一业务的链接通过短息发送到支持WAP的设备,WAP PUSH实现了短信和WAP业务的结合。
    android.permission.CALL_PHONE : 
    Allows an application to initiate a phone call without going through the Dialer user interface for the user to confirm the call being placed.
    允许应用程序不经过用户拨号界面而直接拨号。
    android.permission.CALL_PRIVILEGED :
    Allows an application to call any phone number, including emergency numbers, without going througth the Dialer user interface for confirm the call being palced.
    允许应用程序不经过用户拨号界面而拨打任意号码(包括紧急号码)。(紧急号码是指哪些?)
    android.permission.CAMERA :
    Required to be able to access the camera device.
    访问摄像头设备必须具备的权限。
    android.permission.CHANGE_COMPONENT_ENABLED_STATE : 
    Allows an application to change whether an application component (other than its own) is enabled or not.
    允许一个应用程序改变另一个应用程序组件的启用状态(禁用或启用)。
    android.permission.CHANGE_NETWORK_STATE :
    Allows applications to change network connecitity state.
    允许应用程序更改网络连接状态。
    android.permission.CHANGE_WIFIMULTICAST_STATE :
    Allows applications to enter Wi-Fi Multicast mode.
    允许应用程序进入Wi-Fi Multicast 模式。
    说明:Multicast,多重广播,网络中的一个节点发出的信息被多个节点接收。
    android.permission.CHANGE_WIFI_STATE :
    Allows applications to change Wi-Fi connectivity state.
    允许应用程序更改Wi-Fi连接状态。
    android.permission.CLEAR_APP_CACHE :
    Allows an application to clear the caches of all installed application on the device.
    允许一个应用程序清理所有已安装程序的设备缓冲区 (是安装的时候使用的缓冲区,还是运行时候的缓冲区?)
    android.permission.CLEAR_APP_USER_DATA : 
    Allows an application to clear user data.
    允许一个应用程序清理用户数据。
    android.perimmision.CONTROL_LOCATION_UPDATES :
    Allows enabling/disabling location update notification from the radio.
    允许启用/禁用位置更新的提示信息。(from the radio? 通过电波获得的位置更新信息?)
    android.permission.DELETE_CACHE_FILES :
    Allows an application to delete cache files.
    允许一个应用程序删除cache文件。
    android.permission.DLEETE.PACKAGES :
    Allows an application to delete packages.
    允许一个应用程序删除packages(apk安装包?还是所有类型的压缩包?)
    android.permission.DEVICE_POWER :
    Allows low-level access to power management.
    允许访问底层的电源管理。
    android.permission.DIAGNOSTIC :
    Allows application to RW to diagnostic resources.
    允许应用程序读写诊断资源(diagnostic resources)。(什么事diagnostic resources?诊断信息,log?)
    android.permission.DISABLE_KEYGUARD :
    Allows aplications to disable the keyguard.
    允许应程序禁用键盘锁。
    android.permission.DUMP :
    Allows an application to retrieve state dump information from system services.
    允许一个应用程序从系统服务中抓取(检索)状态转储信息。(什么是state dump?将数据从一个设备转存到另外一个设备?)
    android.permission.EXPAND_STATUS_BAR :
    Allows an applicaton to expand or collapse the status bar.
    允许一个应用程序扩张或收缩状态栏。
    android.permission.FACTORY_TEST :
    Run as an manufacturer test application, running as the root user.
    允许像厂家测试程序那样以root用户权限运行应用程序。
    android.permission.FLSHLIGHT :
    Allows access to the flashlight.
    允许访问闪光信号灯。
    android.permission.FORCE_BACK :
    Allows an application to force a BACK operation on whatever is the top activity.
    允许一个应用程序在activity上强制执行一个回退操作,无论这个activity是否是顶层的activity。
    android.permission.GET_ACCOUNTS :
    Allows access to the list of accouts in the Accounts Service.
    允许访问账号服务的账号列表。
    android.permission.GET_PACKAGE_SIZE :
    Allows an application to find out the space used by any package.
    允许应用程序获得任何package占用的存储空间。
    android.permission.GET_TASKS :
    Allows an appllication to get information about the currently or recently running tasks: a thumbnail representation of the tasks ,what activities are running in it, etc.
    允许一个应用程序获得的当前或最近运行的任务信息:像在任务中运行了哪些activitys等一些简短信息。
    android.permission.GLBOAL_SEARCH :
    This permission can be used on content providers to allow the global search system to access their data.
    拥有该权限的content providers将允许全局搜索系统访问其数据。
    android.permission.HARDWARE_TEST :
    Allows access to hardware peripherals.
    允许访问外设。
    android.permission.INJECT_EVENTS :
    Allows an application to inject user events (keys, touch, trackball) into the event stream and deliver them to ANY window.
    允许一个应用程序向事件流(事件队列)注入用户事件(keys,touch,tarckball),并且将其传递给窗口。
    android.permission.INSTALL_LOCATION_PROVIDER :
    Allows an application to install a locaton provider int the location Manager.
    允许应用程序程序安装一个位置服务到位置管理器。
    androd.permission.INSTALL_PCAKAGES :
    Allows an application to install packages.
    允许一个应用程序安装packages。(用于版本升级的?)
    android.permission.INTERNAL_SYSTEM_WINDOW :
    Allows an application to open windows that are for use by parts of the system user interface.
    允许一个应用程序打开系统用户界面中的窗口。
    android.permission.INTERNET :
    Allows application to open networkd sockets.
    允许应用程序打开网络套接字(sockets)。
    android.permission.KILL_BACKGROUND_PROCESSES :
    Allows an application to call killBackgroundProcesses(String).
    允许应用程序调用killBackgroundProcesses(String)方法。
    android.permission.MANAGE_ACCOUNTS :
    Allows an application to manage the list of accouts in the AccountManager.
    允许应用程序管理AccountManager中的账户列表。
    android.permission.MANAGE_APP_TOKENS :
    Allows an application to manage (create, destroy, Z-order) application tokens in the window manager.
    允许一个应用程序管理(创建、销毁、Z-order)在窗口管理器中的应用程序图标。
    android.permission.MASTER_CLEAR:
    none.
    没任何描述。
    android.permisson.MODIFY_AUDIO_SETTINGS :
    Allows an application to modify global audio settings.
    允许一个应用程序更改全局音频设置。
    android.permission.MODIFY_PHONE_STATE :
    Allows modification of the telephony state – power on, mmi, etc.
    允许修改电话(手机?)状态——上电,人机界面(mmi,Man Machine Interface)等。
    android.permission.MOUNT_FORMAT_FILESYSTEMS :
    Allows formatting file sysytems for removable storage.
    允许格式化移动存储设备。
    android.permission.MOUNT_UNMOUNT_FILESYSYTEMS : 
    Allows mounting and unmounting the file sysytems for removable storage.
    允许加载或卸载移动存储设备。
    android.permission.FERSISTENT_ACTIVITY : 
    Allows an application to make its activities persistent.
    允许一个应程序设置其activities具有持久性(persistent activities是什么样的activites?)。
    android.permission.PROCESS_OUTGOING_CALLS :
    Allows an application to monitor, modify, or abort outgoing calls.
    允许应用程序监视、修改、忽略拨出的电话(拨号)。
    android.permission.READ_CALENDAR :
    Allows an application to read the user’s calendar data.
    允许一个应用程序读取用户日历数据。
    android.permission.READ_CONTACTS :
    Allows an apllication to read the user’s contacts data.
    允许一个应用程序读取用户联系人列表。
    android.permission.READ_FRAME_BUFFER :
    Allows an application to take screen shots and more generally get access to the frame buffer data.
    允许一个应用程序通过访问帧缓冲区(一般一屏就是一帧)获取屏幕截图等帧数据。
    android.permission.READ_HISTORY_BOOKMARKS :
    Allows an application to read (but not write) the user’s browsing history and bookmarks.
    允许一个应用程序读取浏览器的历史记录和书签。
    android.permission.READ_INPUT_STATE :
    Allows an application to retrieve the current state of keys and switches.
    允许一个应用程序获取当前keys和switches的状态(keys、switchs都是输入设备)。
    android.permission.READ_LOGS :
    Allows an application to read the low-level system log files.
    允许一个应用程序读取底层系统的log文件。
    android.permission.READ_OWNER_DATA :
    Allows an application to read the owner’s data.
    允许一个应用程序读取所有者的数据。(手机的owner?)
    android.permission.READ_PHONE_STATE :
    Allows read only access to phone state.
    允许读取(不可写)手机状态。
    android.permission.READ_SMS :
    Allows an application to read SMS messages.
    允许一个应用程序读取手机短消息。
    android.permission.READ_SYNC_SETTING :
    Allows applications to read the sync setting.
    允许应用程序读取同步设置
    android.permission.READ_SYNC_STATS :
    Allows applications to read sync stats.
    允许一个应用程序读取同步状态。
    android.permission.REBOOT :
    Required to be able to reboot the device.
    重启设备必须具有的权限。
    android.permission.RECEIVE_BOOT_COMPLETED :
    Allows an application to receive the ACTION_BOOT_COMPLETED that is boradcast after the sysytem finishes booting.
    允许应用程序获取系统完全启动之后的ACTION_BOOT_COMPLETED广播。
    android.permission.RECEIVE_MMS :
    Allows an application to monitor incoming MMS messages, to record or perform processing on them.
    允许一个应用程序监控收到的彩信(MMS),记录或处理之。
    android.permission.RECEIVE_SMS :
    Allows an application to monitor incoming SMS messages, to record or perform processing on them.
    允许一个应用程序监控收到的短信(SMS),记录或处理之。
    android.permission.RECEIVE_WAP_PUSH :
    Allows an application to monitor incoming WAP push messages.
    允许一个应用程序监测接受的WAP-PSUH消息。
    android.permission.RECORD_AUDIO : 
    Allows an application to record audio.
    允许一个应用程序录音。
    android.permission.REORERD_TASKS :
    Allows an application to change the Z-order of tasks.
    允许一个应用程序改变任务的Z-order(类似于优先级?)。
    android.permission.RESTART_PACKAGES :
    This constant is deprecated. The restartPackage(String) API is no longer supported.
    这个常量已不再使用,restartPackage这个API函数不再有效。
    android.permission.SEND_SMS : 
    Allows an application to send SMS messages.
    允许应用程序发送短消息(SMS)。
    android.permission.SET_ACTIVITY_WATHCER :
    Allows an application to watch and control how activities are started globally in system.
    允许一个应用程序在全局系统中监控activities是如何被启动的。
    android.permission.SET_ALWAYS_FINISH :
    Allows an application to control whether activities are immediately finished when put in the background.
    允许应用程序无论activies是否刚刚结束,都将应用程序置于后台运行。(强制结束activies,置应用程序于后台运行?)
    android.permission.SET_ANIMATION_SCALE :
    Modify the global animation scaling factor.
    修改全局动画缩放比例。
    android.permission.SET_DEBUG_APP :
    Configure an application for debugging.
    为调试配置一个应用程序。
    android.permission.SET_ORIENTATION :
    Allows low-level access to setting the orientation (actually rotation) of the screen.
    允许设置屏幕方向(实际上就是旋转屏幕)。
    android.permission.SET_PREFERRED_APPLICATIONS :
    This constant is deprecated, No longer useful, see addPackageToPreferred(String)for details.
    这个常量已经无效了。
    android.permission.SET_PROCESS_LIMIT :
    Allows application to set the maximum number of (not needed) application processes that can be runing.
    允许应用程序设置最大可用进程数(不是必须的)。
    android.permission.SET_TIME :
    Allows applications to set the system time.
    允许应用程序设置系统时间。
    android.permission.SET_TIME_ZONE :
    Allows applications to set the system time zone.
    允许应用程序设置系统时区。
    android.permission.SET_WALLPAPER :
    Allows applications to set the wallpaper.
    允许应用程序设置桌面。
    android.permission.SET_WALLPAPER_HINTS : 
    Allows application to set wallpaper hints.
    允许应用程序设置桌面提示。(wallpaper hints 是什么东东?) 
    android.permission.SINGAL_PERSISTENT_PROCESSES :
    Allows an application to request that a signal be sent to all persistent processes.
    允许应用程序请求一个发送给所有持续进程的信号(signal)。(persistent processes 是什么样的进程?)
    android.permission.STATUS_BAR :
    Allows an application to open, close, or disable the status bar and its icons.
    允许一个应用程序打开、关闭、禁用状态栏和状态栏图标。
    android.permission.SUBSCRIBED_FEEDS_READ :
    Allows an application to allow access the subscribed feeds ContentProvider.
    允许一个应用程序访问订阅RSS feeds的ContentProvider。
    android.permission.SUBSRIBED_FEEDS_WRITE :
    None.
    没有任何描述。
    android.permission.SYSYTEM_ALERT_WINDOW : 
    Allows an application to open windows using the type TYPE_SYSTEM_ALERT, show on top of all other applications.
    允许应用程序打开一个TYPE_SYSTEM_ALERT类型的系统警告(提示)窗口, 并将其置于顶层显示。
    android.permission.UPDATE_DEVICE_STATS :
    Allows an application to update device statistics.
    允许应用程序更新设备统计信息。
    android.permission.USE_CREDENTIALS :
    Allows an application to request authtokens from the AccountManager.
    允许一个应用程序向AccountManager申请授权标记。
    android.permission.VIBRATE :
    Allows access to the vibrator.
    允许访问振动器。
    android.permission.WAKE_LOCK :
    Allows using PowerManager WakeLocks to keep processor from sleeping or screen from dimming.
    允许使用PowerManager WakeLocks,避免处理器进入休眠,或屏幕变暗。
    android.permission.WRITE_APN_SETTINGS :
    Allows applications to write the apn settings.
    允许应用程序设置APN。
    说明:APN(Acess Point Name)即“接入点名称”,用来标识GPRS的业务种类,目前分为两大类: CMWAP(通过GPRS访问WAP业务)、CMNET(除了WAP以外的服务目前都是CMNET,比如连接因特网等)。
    android.permission.WRITE_CALENDAR :
    Allows an application to write (but not read) the user’s calendar data.
    允许应用程序只写用户日历数据。
    android.permission.WRITE_CONTACTS :
    Allows an application to write (but not read) the user’s contacts data.
    允许应用程序只写用户联系人数据。
    android.permission.WRITE_EXTERNAL_STORAGE :
    Allows an application to write to external storage.
    允许应用程序写数据到外部存储设备(主要是SD卡)。
    android.permission.WRITE_GSERVICES :
    Allows an application to modify the google service map.
    允许应用程序修改google地图服务。
    android.permission.WRITE_HISTORY_BOOKMARKS :
    Allows an application to write (but not read) the user’s browsing history and bookmarks.
    允许一个应用程序写数据到用户浏览器历史记录和书签。
    android.permission.WRITE_OWNER_DATA :
    Allows an application to write (but not read) the owner’s data.
    允许一个应用程序写入(填入)所有者(手机所有者?)的信息。
    android.permission.WRITE_SECURE_SETTINGS :
    Allows an application to read or write the secure system settings.
    允许一个应用程序读写系统安全设置。
    android.permission.WRITE_SETTINGS :
    Allows an application to read or write the system setting.
    允许一个应用程序读写系统设置。
    android.permission.WRITE_SMS :
    Allows an application to write SMS messages.
    允许一个应用程书写短消息。
    android.permisson.WRITE_SYNC_SETTING :
    Allows applications to write the sync setting.
    允许应用程序更改同步设置。
  • 相关阅读:
    简易表格练习
    CSS圆角样式
    力不从心
    学渣在努力~
    嫌疑人
    poj1308 Is it a tree?
    悲剧文本
    迷宫问题
    n皇后问题
    油田
  • 原文地址:https://www.cnblogs.com/badboy/p/2183726.html
Copyright © 2011-2022 走看看