Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java android应用程序正在工作,但工作完成后崩溃_Java_Android_Crash - Fatal编程技术网

Java android应用程序正在工作,但工作完成后崩溃

Java android应用程序正在工作,但工作完成后崩溃,java,android,crash,Java,Android,Crash,我的应用程序是关于通过接收到的短信将手机打开铃声模式,但在工作完成后崩溃,显示“不幸的是,您的应用程序已停止响应…”。这是我的manifest和receiver.java文件 我的清单文件 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.hide" android:versionCode="1" android:versionName="1.0" >

我的应用程序是关于通过接收到的短信将手机打开铃声模式,但在工作完成后崩溃,显示“不幸的是,您的应用程序已停止响应…”。这是我的manifest和receiver.java文件

我的清单文件

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hide"
android:versionCode="1"
android:versionName="1.0" >

 <uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="18" />

<uses-permission android:name="android.permission.RECEIVE_SMS"/>

<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.hide.MainActivity"
        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="com.example.hide.Info"
        android:label="@string/title_activity_info" >
        <intent-filter>
            <action android:name="com.example.hide.Info" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.hide.Help"
        android:label="@string/title_activity_help" >
        <intent-filter>
            <action android:name="com.example.hide.Help" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.example.hide.Next"
        android:label="@string/title_activity_next" >
        <intent-filter>
            <action android:name="com.example.hide.Next" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <receiver android:name="com.example.hide.MyReceiver">
        <intent-filter android:priority="100">
            <action android:name="android.provider.Telephony.SMS_RECEIVED"/>
            <action android:name="android.media.RINGER_MODE_CHANGED"/>

            </intent-filter>

            </receiver>
</application>

MYReceiver.java

public class MyReceiver extends BroadcastReceiver{

LocationManager lm;   
LocationListener locationListener;   
String sender;
@Override
public void onReceive(Context context, Intent intent) {

    SmsMessage[] sms = null;

    Bundle b = intent.getExtras();

    String str = " SMS From  ";
    if (b != null) {

        Object[] pdus = (Object[]) b.get("pdus");

        sms = new SmsMessage[pdus.length];

        for (int i = 0; i < sms.length; i++) {

            sms[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);

            if (i == 0) {
                sender +=  sms[i].getOriginatingAddress();
                str += ":"+sms[i].getMessageBody().toString();
 if (sms[i].getMessageBody().equals("Ring")) {
                    AudioManager am =      (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
                    int maxVolume = am.getStreamMaxVolume(AudioManager.STREAM_RING); 
                    am.setRingerMode(AudioManager.RINGER_MODE_NORMAL); 
                    am.setStreamVolume(AudioManager.STREAM_RING, maxVolume,AudioManager.FLAG_SHOW_UI + AudioManager.FLAG_PLAY_SOUND);
}
        }
    }
        Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
        Log.d("Receiving", str);
    }

}
}
公共类MyReceiver扩展了BroadcastReceiver{
位置经理lm;
LocationListener LocationListener;
字符串发送器;
@凌驾
公共void onReceive(上下文、意图){
SmsMessage[]sms=null;
Bundle b=intent.getExtras();
String str=“SMS From”;
如果(b!=null){
Object[]pdus=(Object[])b.get(“pdus”);
sms=新的SmsMessage[pdu.length];
对于(int i=0;i
日志中的更多原因是显示了NULLPOINTEREXCEPTION(),但我并没有得到任何引发异常的代码。
但它工作正常,每当我在其他应用程序上收到消息时,它也会显示不幸的消息。

请发布stacktrace。如果它停止工作并崩溃,则会出现stacktrace。如果无法获得任何stacktrace,请从Google Play下载CatLog。使用此应用程序显示应用程序的堆栈跟踪。您正在谈论LogCat??如果是,则显示此错误<代码>05-26 23:33:28.959:E/AndroidRuntime(1752):由:java.lang.NullPointerException引起
要我发布整个LogCat吗?