WallpaperService is not launching - android

I want to create my own animated wallpaper. I have no errors but service don't start, logs says nothing. I think the problem is with intent launch or manifest but i can't find solution.
Launching code:
val intent = Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
intent.putExtra(
WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
ComponentName(this, EyesWallpaperService::class.java)
)
startActivity(intent)
Manifest:
...
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-feature
android:name="android.software.live_wallpaper"
android:required="true"/>
<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/Theme.EyesWallpaper">
<service
android:name=".EyesWallpaperService"
android:label="EYES Wallpaper"
android:permission="android.permission.BIND_WALLPAPER"
android:exported="true">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:value="#xml/wall" />
</service>
<activity
android:name=".MainActivity"
android:exported="true"
android:label="#string/app_name"
android:theme="#style/Theme.EyesWallpaper">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
...
And WallpaperService:
class EyesWallpaperService : WallpaperService() {
...
override fun onCreateEngine(): Engine {
Log.v("EYEInfo", "init")
return MyEngine()
}
inner class MyEngine : Engine() {
...
}
}

Related

animated splash screen doesn't appear

In this project I tried to make an animated splash screen which will appear before going to the main activity, but after I execute, the splash screen does not appear but instead goes directly to the main activity.
how to fix this?
this is my splash activity class
private ImageView container;
private AnimationDrawable animationDrawable;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash)
container = findViewById(R.id.iv_icons);
container.setBackgroundResource(R.drawable.mysplash_animation);
animationDrawable = (AnimationDrawable) container.getBackground();
}
#Override
protected void onResume() {
super.onResume();
animationDrawable.start();
checkAnimationStatus(50, animationDrawable);
}
private void checkAnimationStatus(final int time, final AnimationDrawable animationDrawable) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
#Override
public void run() {
if (animationDrawable.getCurrent() != animationDrawable.getFrame(animationDrawable.getNumberOfFrames() - 1))
checkAnimationStatus(time, animationDrawable);
else finish();
}
}, time);
}
}
and this is my manifest.xml
<application
android:allowBackup="true"
android:exported="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.NoActionBar">
<activity android:name=".SplashActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
You have to change this in your manifest(you have to give launcher activity to splashActivity)
<application
android:allowBackup="true"
android:exported="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.NoActionBar">
<activity android:name=".SplashActivity">
// below code you have to add //
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
//Remove from here//
</activity>
</application>
Set your Splash Activity as the Launcher activity:
<activity android:name=".MainActivity"></activity>
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Please provide intentfilter to SplashActivity
<application
android:allowBackup="true"
android:exported="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.NoActionBar">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity">
</activity>
</application>

how to detect incoming call

i have code in file manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ninhph.btvncallblock">
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<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=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.AddActivity" />
<receiver android:name=".receiver.CallReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>
</manifest>
and in broadcastReceiver:
package com.ninhph.btvncallblock.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class CallReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Log.d("call", "call coming: ");
}
}
But when i run and call in emulator, nothing happen, why? and how can i detect incoming call?
add <uses-permission android:name="android.permission.PROCESS_INCOMING_CALLS"/> permission in AndroidManifest.xml also try set priority to intent filter like below code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ninhph.btvncallblock">
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.PROCESS_INCOMING_CALLS"/>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<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=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.AddActivity" />
<receiver android:name=".receiver.CallReceiver">
<intent-filter android:priority="999">
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>
</manifest>
in receiver code
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class CallReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Log.d("call", "call coming: ");
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
Toast.makeText(context, "Hey! Calling Number : " + incomingNumber, Toast.LENGTH_LONG).show();
}
}
}

Background service using alarm manager

I have followed below example code for implementing Periodic background service. Periodic task executes correctly If app on foreground on 1st time. If, I close application then Background service is not working.
https://github.com/codepath/android_guides/wiki/Starting-Background-Services#using-with-alarmmanager-for-periodic-tasks
1) BroadcastReceiver service for Bootcomplete
public class BootBroadcastReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
// Launch the specified service when this message is received
Intent startServiceIntent = new Intent(context, MyTestService.class);
context.startService(startServiceIntent);
}
}
2) BroadcastReceiver to start service
public class MyAlarmReceiver extends BroadcastReceiver {
public static final int REQUEST_CODE = 12345;
// Triggered by the Alarm periodically (starts the service to run task)
#Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MyTestService.class);
i.putExtra("foo", "bar");
context.startService(i);
Toast.makeText(context, "Welcome --------1", Toast.LENGTH_LONG).show();
}
}
3) IntenetService class: To execute my background task
public class MyTestService extends IntentService {
// Must create a default constructor
public MyTestService() {
// Used to name the worker thread, important only for debugging.
super("test-service");
}
#Override
public void onCreate() {
super.onCreate(); // if you override onCreate(), make sure to call super().
}
#Override
protected void onHandleIntent(Intent intent) {
}
}
4) Service is started from activity as
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scheduleAlarm();
}
// Setup a recurring alarm every half hour
public void scheduleAlarm() {
// Construct an intent that will execute the AlarmReceiver
Intent intent = new Intent(getApplicationContext(), MyAlarmReceiver.class);
// Create a PendingIntent to be triggered when the alarm goes off
final PendingIntent pIntent = PendingIntent.getBroadcast(this, MyAlarmReceiver.REQUEST_CODE,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Setup periodic alarm every 5 seconds
long firstMillis = System.currentTimeMillis(); // alarm is set right away
AlarmManager alarm = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
// First parameter is the type: ELAPSED_REALTIME, ELAPSED_REALTIME_WAKEUP, RTC_WAKEUP
// Interval can be INTERVAL_FIFTEEN_MINUTES, INTERVAL_HALF_HOUR, INTERVAL_HOUR, INTERVAL_DAY
alarm.setRepeating(AlarmManager.RTC_WAKEUP, firstMillis,
30000, pIntent);
}
}
5) Manifest file
<?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="test.org.help">
<permission
android:name="test.org.help.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="au.com.KPS.companion.ACCESS_DATA" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="test.org.help.permission.UA_DATA" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- This app has permission to register with GCM and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="test.org.help.permission.C2D_MESSAGE" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.flash"
android:required="false" />
<uses-feature android:name="android.hardware.screen.landscape" />
<application
android:name="test.org.help.KPSApp"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:logo="#drawable/ic_actionbar_logo"
android:theme="#style/AppTheme"
tools:replace="android:icon, android:logo">
<!-- Activities -->
<activity
android:name="test.org.help.ui.activity.SplashActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activity.JanRainLoginActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activity.LinkListActivity"
android:screenOrientation="portrait" />
<activity
android:name="test.org.help.ui.activity.KPSFragmentActivity"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"></activity>
<activity
android:name="test.org.help.ui.activity.NotificationDialogActivity"
android:excludeFromRecents="true"
android:label=""
android:launchMode="singleInstance"
android:noHistory="true"
android:screenOrientation="portrait"
android:taskAffinity=""
android:theme="#style/AppTheme.Dialog.Notification"></activity>
<receiver
android:name="test.org.help.receivers.NotificationReceiver"
tools:ignore="ExportedReceiver">
<intent-filter>
<action android:name="test.org.help.util.ACTION_SHOW_AGENDA" />
<action android:name="test.org.help.util.ACTION_SNOOZE" />
<action android:name="test.org.help.util.ACTION_DISMISS" />
<action android:name="test.org.help.util.ACTION_SHOW_DIALOG" />
<data android:scheme="KPS" />
<data android:mimeType="text/plain" />
<data android:pathPattern="au\.org\.KPS\.util/.*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.Light.NoTitleBar"
tools:replace="android:theme,android:screenOrientation"></activity>
<activity
android:name="test.org.help.ui.activity.AppTutorialActivity"
android:screenOrientation="portrait"
android:theme="#style/SplashTheme"></activity>
<activity
android:name="test.org.help.ui.activity.TermsAndConditionsActivity"
android:label="#string/title_terms_and_conditions"
android:screenOrientation="portrait"></activity>
<activity
android:name="test.org.help.ui.activity.WarningActivity"
android:label="#string/title_Warning"
android:screenOrientation="portrait"></activity>
<activity
android:name="test.org.help.ui.activity.DifferentUserWarningActivity"
android:label="#string/title_Warning"
android:screenOrientation="portrait"></activity>
<activity
android:name="test.org.help.ui.activity.AppWhatsNewActivity"
android:label="#string/title_Warning"
android:screenOrientation="portrait"></activity>
<activity
android:name=".ui.activity.UserUpgradeActivity"
android:label="#string/title_upgrade"
android:screenOrientation="portrait"></activity>
<activity
android:name="eu.janmuller.android.simplecropimage.CropImage"
android:label=""
android:screenOrientation="portrait"></activity>
<!-- Facebook -->
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<!-- Services -->
<receiver android:name="com.mobileapptracker.Tracker">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service
android:name="test.org.help.service.DBUpdateService"
android:exported="false"
android:label="#string/app_name">
<intent-filter>
<action android:name="test.org.help.service.DBUpdateService"></action>
</intent-filter>
</service>
<receiver android:name="test.org.help.receivers.TimeChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
</receiver>
<activity
android:name="com.janrain.android.engage.ui.JRFragmentHostActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name="com.janrain.android.engage.ui.JRFragmentHostActivity$Fullscreen"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" />
<!--Hockey app crash report-->
<meta-data
android:name="net.hockeyapp.android.appIdentifier"
android:value="#string/hockey_app_id" />
<receiver android:name="test.org.help.syncmanager.Network.NetworkAvailability">
<intent-filter>
<action android:name=".android.action.broadcast" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
<activity
android:name=".db.AndroidDatabaseManager"
android:theme="#style/Theme.AppCompat.Light" /><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<service
android:name=".syncmanager.auto.MyTestService"
android:exported="false" />
<receiver
android:name=".syncmanager.auto.MyAlarmReceiver"
android:process=":remote"></receiver>
<receiver android:name=".syncmanager.auto.BootBroadcastReceiver">
</receiver>
</application>
</manifest>
If, implement above as sample project as separate then, background service is executing fine always. But If try to integrate with my existing code then not working...
Edited: Found Solution
It got resolved by adding full path android:name service in AndroidManifest.xml
<service
android:name="test.org.help.syncmanager.auto.MyTestService"
android:exported="false" />

Firebase notification is not working when the activity is on the foreground

I don't have problem with the notification when my app is in the background. Can someone tell me why?
This is my manifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".CrowdWeather"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
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>
<service
android:name=".FirebaseNotification">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
</application>
This is the FirebaseNotification.java:
public class FirebaseNotification extends FirebaseMessagingService {
public static final String TAG= "Firebase rocks";
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d("getFrom",remoteMessage.getFrom()+" ");
Log.d("messageData",remoteMessage.getMessageType()+" ");
Log.d("notificationBody",remoteMessage.getNotification().getBody() +" ");
Log.d("total",remoteMessage.getTtl()+" ");
}
}

Android: Why I am not receiving the BOOT_COMPLETED intent?

I am testing on an physical device (SAMSUNG ACE GT S5830i)
But I am not receiving the BOOT_COMPLETED intent therefore the service is not Receiver is not starting
This is the code I am using.
public class BootCompleteReceiver extends BroadcastReceiver {
static final String TAG = "InfoService.BroadcastReceiver";
#Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Log.e(TAG, "System boot notification received.");
Intent service = new Intent(context, InfoService.class);
context.startService(service);
} else {
Log.e(TAG, "Intent received: " + intent);
}
}
}
This is the Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appengine.paranoid_android.lost"
android:versionCode="2"
android:versionName="1.1">
<application android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<activity android:name=".InfoSetup"
android:label="#string/activity_name"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LockScreen"
android:label="#string/activity_name"
android:launchMode="singleInstance"
android:clearTaskOnLaunch="true"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
<service android:name=".InfoService"
android:label="#string/service_name"/>
<receiver android:name=".BootCompleteReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_CHANGED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<!-- <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/> -->
Try to add the full path with the package for <receiver android:name=".BootCompleteReceiver">
<receiver android:name="com.appengine.paranoid_android.lost.BootCompleteReceiver">

Categories

Resources