I need that when I unlock my cellphone, my app shows up inmediately

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

I need that when I unlock my cellphone, my app shows up inmediately



I need my cell phone to unlock it in my application automatically. The question is what do I do with a receiver ACTION_USER_PRESENT, but it has not worked for me. Some help?



I am working in android studio. Java



Receiver:


package com.example.juan.educandote;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class Monitor extends BroadcastReceiver

Monitor screen;


@Override
public void onReceive(Context arg0, Intent arg1)

if (arg1.getAction().equals(Intent.ACTION_USER_PRESENT))
Intent IntentInitiateApplication;
IntentInitiateApplication = new Intent(arg0, MainActivity.class);
IntentInitiateApplication.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
arg0.startActivity(IntentInitiateApplication);





manifest


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.juan.educandote">


<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


<receiver android:name=".Monitor">
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>

</application>

</manifest>









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Mass disable jenkins jobs