Android ACTION_BOOT_COMPLETED called everytime?
- by user3976029
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.