android-service

START_STICKY of onStartCommand in Android 6.0.0

 ̄綄美尐妖づ 提交于 2019-12-13 17:52:12
问题 I am working with some application which starts a service . When I close app under Android 7.0.0 its service is continue working fine. But under Android 6.0.0 it does not. I use this snippet to keep working service @Override public int onStartCommand(Intent intent, int flags, int startId) { // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY; } What do I missing here? Code of the service class import android.Manifest; //import

What is the format for an android intent?

人走茶凉 提交于 2019-12-13 17:14:51
问题 I'd like to know what is the format for an android intent. IE, what should I pass to the method : getBaseContext().startService(Intent); If I want to pass this: android.provider.CallLog.Calls.CONTENT_URI can i? What would be the format. Can someone give a good explanation of how to use Intents, and how to use it on Service implementation, like, startService() , or onStartCommand (Intent intent, int flags, int startId) . Thanks! 回答1: Just to call a new Activity this is the method.

Several audio recording in Android

我是研究僧i 提交于 2019-12-13 15:22:06
问题 I have an android code who should record several audios. The first recording is performing well, I click on record, than on stop and it's all ok! But if I click another time on record I get a crash! What am I doing wrong? btnEnregistrement = (ImageButton) findViewById(R.id.button_lancer_enregistrement); btnEnregistrement.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(btnEnregistrement.getTag().equals("false")){ btnEnregistrement

Android: When a service is killed, how can we persist the service state for later restoration?

给你一囗甜甜゛ 提交于 2019-12-13 13:12:39
问题 We have created an app that is essentially a timer/stopwatch with some decked out features. We defined a service that ticks the clock and alerts listeners (activities, etc.) who are subscribed to certain timer events. We would like to be able to save the state of the timer/stopwatch (elapsed seconds, time until next event, user-provided config etc.) whenever android kills our service (for memory recollection), and then restore the state of the service when the app is restored by the user. For

Why unbind Service onDestroy?

て烟熏妆下的殇ゞ 提交于 2019-12-13 11:48:48
问题 I've seen it mentioned in multiple sources, that if an Activity binds a Service, it should unbind it onDestroy. Why? Since the Activity is destroyed, it seems like the service will be unbound anyway. If it was "started" - it doesn't matter anyway. And if it was auto-started by the activity - it will close anyway if no others bound it. So why unbind it? 回答1: Activities need to handle configuration changes, such as when the screen is rotated, or the user changes locales, or the device enters

I want to show gif image show on screen even when app is closed

六眼飞鱼酱① 提交于 2019-12-13 08:50:04
问题 With a mouse click, you implement two things: Sound is playing The GIF image is showing I'm trying to show the GIF on the screen even when I close the app I'm using the services but because the sound keeps playing while the GIF image appears, I can not find the solution. TheService.java (CODE) package gallery.suitapps.catwalking; import android.app.Service; import android.content.Context; import android.content.Intent; import android.media.MediaPlayer; import android.media.SoundPool; import

KeyGuard lock using Service Android

寵の児 提交于 2019-12-13 08:45:56
问题 I have activity in which i am using http://code.google.com/p/android-lockpattern/ this library Pattern Design for key lock successfully locking the screen within the activity button. But when i implement a service to do this same process in background after some interval of time. The problem is that when i start the service from activity to perform lock function its keep giving me null pointer Below is my code of main activity. package com.example.lockscreen_test; import group.pals.android

Create a log of all keyboard key pressed during a day in android

北城以北 提交于 2019-12-13 07:51:55
问题 I am new in android and want to create a log file of all key strokes pressed on keyboard in an android device. My app will display all the key pressed in a log file containing the key value and exact keyboard value of any type of keyboard user uses. As I know we can run our app in background using services and broadcastreciver concept, but i want to trap all the key strokes values to be stored in the log file from any other app or phone operation. Thanks for the help. 回答1: The best way for

How to stop a running service using broadcast receiver in android

时光总嘲笑我的痴心妄想 提交于 2019-12-13 07:37:33
问题 I think there is a simple problem in my code but I couldn't figure it out. I have a HeaderService which shows a bubble popup over some particular apps. Now what I want is stop that service when user presses Home key or Back key using BroadCastReceiver. Please take a look at my code and suggest me some solution. Thanks in Advance!! This is my Receiver class public class PopupClosingReceiver extends BroadcastReceiver { private boolean isMyServiceRunning(Context con) { ActivityManager manager =

Oreo: how to catch location update from the background?

五迷三道 提交于 2019-12-13 06:30:54
问题 I migrate my app to oreo (as it's requiered by google play now), and i have now an error when i start my phone : Not allowed to start service Intent My app is listening in background any location update and send periodically those grabbed locations to a server. for this i do : in AndroidManifest.xml <receiver android:name="com.myapp.StartServiceBroadcastReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> in the