BroadcastReceiver can be registered either in Activity (dynamically) or statically (registered in the manifest). With the first questions no. The second method fails. I read on the site that in order for the manifest to register, you need to start the Activity , but this also does not work. I decided to ask you for help. Here is the source code:

 JustBroadcastReceiver.java: public class JustBroadcastReceiver extends BroadcastReceiver { public static Context mContext; @Override public void onReceive(Context context, Intent intent) { if(mContext==null) mContext=context; StringBuilder strb=new StringBuilder("Текущая дата: "); Format fformat=new SimpleDateFormat("hh:mm:ss a"); strb.append(fformat.format(new Date())); Toast.makeText(context, strb, Toast.LENGTH_LONG).show(); } } withoutactitivity.xml: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.withoutactitivity" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".JustBroadcastReceiver" 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=".JustBroadcastReceiver" android:enabled="true" android:exported="false" > <intent-filter> <action android:name="android.intent.action.TIME_TICK" /> </intent-filter> </receiver> </application> </manifest> 

    1 answer 1

    I read on the site that you need to run the activation so that the manifest registers

    run from such a site.

    All Service 's and BroadcastReceiver`s declared in the manifest are registered in the system when installing the application.

    and secondly, sometimes pay attention to the documentation. it says everything:

    public static final String ACTION_TIME_TICK

    Broadcast Action: The current time has changed. Sent every minute. You can not receive it through Context.registerReceiver ().

    • Thank you very much! We will know ... I am not yet accustomed to English documentation) made conclusions. - bogman