Activity can't start from broadcast receiver

physical activity
benefits of physical activity
exercise
social benefits of exercise
physical activity examples
mental benefits of exercise
benefits of exercise articles
psychological benefits of exercise

Start Activity from Broadcast receiver is not working on android 9 but its working below android 9 it's working fine, I searched a lot regarding this but could not find the suitable solution. Does anyone face the same problem, here is my code .

public void onReceive(final Context context, Intent intent) {

    try {
        this.tm = (TelephonyManager) context.getSystemService("phone");
        this.tm.listen(new PhoneStateListener() {
            public void onCallStateChanged(int state, final String num) {
                if (state == 1 && Receiver.this.preferences.getInt("start", 0) == 1) {
                    try {
                        new Handler().postDelayed(new Runnable() {
                            public void run() {
                                Receiver.this.i = new Intent(context, MainActivity.class);

                                context.startActivity(Receiver.this.i);
                            }
                        }, 300);
                    } catch (Exception e) {

                    }
                } 

I see that you're listening to onCallStateChanged. But I think you need to ask permission for that on Android 9: https://stackoverflow.com/a/52025013/2212770

Benefits of Physical Activity | Physical Activity, Regular physical activity can help keep your thinking, learning, and judgment skills sharp as you age. It can also reduce your risk of depression and anxiety and  Benefits of Physical Activity Regular physical activity can help children and adolescents improve cardiorespiratory fitness, build strong bones and muscles, control weight, reduce symptoms of anxiety and depression, and reduce the risk of developing health conditions such as: 1

you need to add flag to the intent

i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

before you call context.startActivity(i);

Physical Activity Can Be Helpful in the Coronavirus Pandemic , Each session of physical activity boosts mood and reduces anxiety, so being active every day can be a partial antidote to the stress of the  Open the Activity app on your Apple Watch. Go to your rings, then firmly press the screen. Tap to increase or decrease the number of active calories for your daily Move goal. When you're done, tap Update. You can change the Move goal, but not your Exercise or Stand goals.

Below I send on example for starting activity from the broadcast receiver, But this one is for starting the MainActivity after device reboot.

public class StartReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action= intent.getAction();
        if( action.equals("android.intent.action.BOOT_COMPLETED") ){

            Intent i= new Intent(context, MainActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            context.startActivity(i);
        }
    }

}

[PDF] Physical Activity Guidelines for Americans, 2nd edition, Women who habitually engaged in vigorous-intensity aerobic activity or who were physically active before pregnancy can continue these activities during  You can also tap ‘edit students’ to assign the activity to individual students within a class. Then, tap ‘share with classes’. All activities will appear in the Activities tab in Seesaw. Students will tap the Activities tab to see new activities. All student responses will be stored with their name under the activity.

Android Q (API level 29) and higher place restrictions on when apps can start activities when the app is running in the background.

https://developer.android.com/guide/components/activities/background-starts

However, you can achieve this by giving alert window permission.

How to start a activity from a broadcast receiver when the screen is locked in Android Q

It is working like a charm

Physical Activity, Regular physical activity can improve the health and quality of life of Americans of all ages, regardless of the presence of a chronic disease or disability. Among  You can allow or block any of the sites directly from the recent activity report by selecting Allow or Block next to the URL. To adjust your child's web browsing restrictions, select Settings. Apps & games. Here you can see all the apps and games your child has been using, including any that were blocked.

Exercise: 7 benefits of regular physical activity, Exercise can help prevent excess weight gain or help maintain weight loss. When you engage in physical activity, you burn calories. The more intense the activity,  If you have a personal Microsoft account (MSA), you can manage the activity history data that is associated with your Microsoft account in the cloud by selecting Manage my Microsoft account activity data. Once you’ve signed in to the privacy dashboard, select the Activity history tab, and then select the data you want to manage.

How physical activity can work?, Int J Pediatr Obes. 2008;3 Suppl 1:10-4. doi: 10.1080/17477160801896481. How physical activity can work? Fogelholm M(1). Author information: (1)Academy of  To make this activity successful, you will have to set some rules like the duration of the video, the kind of props that can be used for the, who does what, what background music to pick, and so on. Objective: Communication, creativity, and teamwork are the three objectives of this game.

Benefits of Exercise: MedlinePlus, For older adults, research shows that doing balance and muscle-strengthening activities in addition to moderate-intensity aerobic activity can help  Activity Connection provides senior activities programming and planning for the recreational therapist, activity director, or nursing home administrator. We save you time, money and worry.

Comments
  • please show where you registered the broadcast receiver
  • Try this github.com/devggaurav/…
  • @VladyslavMatviienko why not, I helped him figure out what's the problem. I only added the link as a reference.
  • because it is not yourth. That is intellectual property of other people. If the question has already been answered - you should mark it as duplicate instead.