Android ACTION_BOOT_COMPLETED called everytime?

Posted by user3976029 on Stack Overflow See other posts from Stack Overflow or by user3976029
Published on 2014-08-25T16:11:59Z Indexed on 2014/08/25 16:19 UTC
Read the original article Hit count: 192

Filed under:
|
|

I am trying to write a code in Android , to create a condition during booting but my condition satisfies everytime ( during booting as well as during running of the device also). I am trying to do is , to execute the condition during the booting only.

My Code :

MainActivity.java

package com.example.bootingtest;

import android.os.Bundle;
import android.widget.Toast;
import android.app.Activity;
import android.content.Intent;

public class MainActivity extends Activity 
{

@Override
protected void onCreate(Bundle savedInstanceState) 
{

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    if (Intent.ACTION_BOOT_COMPLETED!=null) 
    {

        Toast.makeText(getApplicationContext(), "Device is booting ...", Toast.LENGTH_LONG).show();

    }

} }

I have given manifest permission .

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

I want to execute this condition only during booting or device start-up but this condition satisfies every time , whenever i open the app.

Please suggest me , how can i run the condition only during the device booting or start-up.

Please help me out.

© Stack Overflow or respective owner

Related posts about android

Related posts about device