我只有一個CallBroadcastReceiver擴展BroadcastReceiver和宣佈的宣言。應用程序只有BroadcastReceiver不工作
仍然沒有顯示吐司,而我正在打出電話。 你能幫忙嗎?
其表示
[2016-02-27 10:02:20 - OnlyReciever] No Launcher activity found!
[2016-02-27 10:02:20 - OnlyReciever] The launch will only sync the application package on the device!
代碼下面 -
CallBroadcastReceiver.class
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
/**
* @author Cosmos
*
*/
public class CallBroadcastReceiver extends BroadcastReceiver
{
public CallBroadcastReceiver() {}
@Override
public void onReceive(Context context, Intent intent)
{
Toast.makeText(context, intent.getAction(), Toast.LENGTH_LONG).show();
}
}
的Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ind.example.onlyreciever"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-sdk
android:minSdkVersion="22"
android:targetSdkVersion="22" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name="ind.example.onlyreciever.CallBroadcastReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>
</manifest>
你不需要在這個項目中的任何活動,是嗎? – astuter
@astuter是的,我認爲是這樣的......我只需要在打出電話時顯示祝詞。我需要一個這樣的活動嗎? – Bharat
@astuter可以做到。但我認爲這不是必需的。看看這個鏈接[沒有mainActivity的應用程序示例](https://www.youtube.com/watch?v=htU_Rd-DW2U) – Bharat