마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

부팅시 .... 에러좀 봐주세요...

0 추천

액티비티에서

버튼누르면

리시버로 연결 후

부팅시 로그뜨게 해 놨습니다...

 

전체 코드 입니다... 왜 부팅 코드에서 에러가 나는 거일까요...

public class MainActivity extends Activity {

 private PendingIntent pendingIntent;
 
 
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  
  Button btn = (Button)findViewById(R.id.button1);
  
  btn.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    Intent i = new Intent( MainActivity.this, Reciver.class );
    pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, i, 0);
    try {
      
     pendingIntent.send();
    } catch (CanceledException e) {
             
    e.printStackTrace();
    }
    
   }
  });

-----------------------------------------------------------

public class Reciver extends BroadcastReceiver {
 
 //private PendingIntent pendingIntent;
 @Override
 // On every interval, the Intent is received here
 public void onReceive(Context context, Intent intent) {
   if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
    Log.e("mylog","onReceive");
         Toast.makeText(context, "ddddddddddddddddddddd", Toast.LENGTH_LONG).show();
   }
  
  Log.e("mylog","onReceiveeeeeeeeeeeeee");
 }

}

---------------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="cuber.sendreciver"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="cuber.sendreciver.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>
        <receiver android:name=".Reciver">
    <intent-filter>
        <action android:name="android.intent.action.PHONE_STATE"/>
      <action android:name="android.intent.action.BOOT_COMPLETED"/>
     </intent-filter>
    </receiver>
       
    </application>

</manifest>

 

뱅뱅뱅기 (280 포인트) 님이 2013년 5월 30일 질문
뱅뱅뱅기님이 2013년 5월 30일 수정

1개의 답변

0 추천

Reciver 15섯번째 줄 널포인터 라네요.

  (11,920 포인트) 님이 2013년 5월 30일 답변
...