2013-04-18 2 views
0

APP의 자동 시작 기능에 문제가 있습니다.APP 자동 시작 방법 APP

포럼을 통해 많은 제안을 찾았습니다. 아무 것도 작동하지 않는 이유를 모르겠습니다.

가 여기에 BootUpReciver.java에게

package com.???.???; 

import android.content.BroadcastReceiver; 
import android.content.Context; 
import android.content.Intent; 
import android.util.Log; 
import android.widget.Toast; 

public class BootUpReciver extends BroadcastReceiver { 

@Override 
public void onReceive(Context context, Intent intent) { 
    if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { 
     //Intent pushIntent = new Intent(context, BackgroundService.class); 
     //context.startService(pushIntent); 

     Toast.makeText(context, "Device Booted", Toast.LENGTH_LONG).show(); 
     Log.d("TAG","Device Booted"); 

    } 
} 
} 

있어 그리고 여기 내 매니페스트 파일

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

<uses-permission android:name="android.permission.VIBRATE"/> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 

<uses-sdk 
    android:minSdkVersion="14" 
    android:targetSdkVersion="17" /> 

<application 
    android:theme="@android:style/Theme.Holo" 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" > 

    <receiver android:name=".BootUpReciver"> 
     <intent-filter> 
      <action android:name="android.intent.action.BOOT_COMPLETED" /> 

      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </receiver> 

    <activity 
     android:name="com.???.???.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> 
</application> 

난 내 휴대 전화를 다시 시작하면 내가 심지어 토스트를 알 수 없어, 왜? 나는 어떻게해야합니까? 일부 sharedprefs를 얻고 부팅 할 때마다 파일에 값을 쓰려면 자동 시작해야합니다.

감사합니다.

+0

디버그하고 부팅 후 onreceive가 호출되는지 확인하십시오. – stinepike

+0

StinePike, 어떻게해야합니까? 재부팅 후에도 디버깅이 가능합니까? o_o 또는 LogCat 이벤트를 확인 하시겠습니까? – Dunnow

+0

내가 확인하자. – stinepike

답변

0

내가 테스트 한 동안 onReceive에서 토스트를 표시하면 표시되지 않습니다. 하지만 onReceive에서 활동을 시작하면 효과가 있습니다. 그래서 이것을 확인할 수도 있습니다. 활동이나 서비스를 시작하고 거기서 당신의 일을 수행하십시오.

+0

시도해 주셔서 감사합니다. 감사합니다. 4 정보 – Dunnow