0

I'm doing my college project which was Parental Control app. In that I'm creating a Custom Receiver. I'm tested that app in jelly bean,kitkat,lollipop, marshmallow, naughat ,oreo. But it only works in jelly bean and kitkat. I'm tried reading all solutions in stackoverflow. Please give solution for me!

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.nizam.training.parentalcontrol">
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />


<application
    android:fullBackupContent="false"
    android:allowBackup="true"
    android:icon="@mipmap/m"
    android:label="@string/app_name"
    android:logo="@mipmap/ico"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <service
        android:name=".BlockService"
        android:enabled="true"
        android:exported="true"/>

    <activity android:name=".AppSettingActivity">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>
    </activity>
    <activity
        android:name=".BlockActivity"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
    <activity
        android:name=".MainActivity"
        android:theme="@style/Theme.AppCompat.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".LoginActivity"
        android:label="Login"
        android:theme="@style/MyTheme" />
    <activity
        android:name=".SignupActivity"
        android:label="Create Pin"
        android:theme="@style/MyTheme" />
    <activity
        android:name=".TaskList"
        android:label="Tasks"
        android:theme="@style/AppTheme">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
        </intent-filter>
    </activity>

    <receiver
        android:name=".MyReceiver"
        android:enabled="true"
        android:exported="true"
        android:permission=""
        tools:ignore="ExportedReceiver">
        <intent-filter>
            <action android:name="StartupReceiver_Manual_Start" />
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </receiver>
    <receiver android:name=".CheckRunningApplicationReceiver" />
</application></manifest>

Calling broabcast in TaskListActivity.java

getApplicationContext.sendBroadcast(new Intent("StartupReceiver_Manual_Start"))

LogCat

http://mnktalktech.blogspot.com/2019/02/logcat-for-parentalcontrol.html

MnkDude
  • 1,028
  • 1
  • 6
  • 14

3 Answers3

0

I found this; it might be part of the issue. Are you getting any errors?

GET_TASKS Permission Deprecated

0

Please try with this.

<receiver
        android:name=".MyReceiver"
        android:enabled="true"
        android:exported="false"
        >
        <intent-filter>
            <action android:name="StartupReceiver_Manual_Start"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </receiver>

and let me know.

amitava
  • 505
  • 1
  • 5
  • 10
0

After spending a week in this issue I have found solution for this. What I put before (which is not working)...

getApplicationContext.sendBroadcast(new Intent("StartupReceiver_Manual_Start"))

Now I just changed.

MyReceiver mr=new MyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("StarctupReceiver_Manual_Start");
registerReceiver(mr,intentFilter);
getBaseContext().getApplicationContext().sendBroadcast(new Intent("StarctupReceiver_Manual_Start"));

I don't know why it is working but it works.If anyone know the reason please comment. Thanks for all who tried to solve this issue.

MnkDude
  • 1,028
  • 1
  • 6
  • 14