android-service

Turn on Unknown Sources setting programmatically

故事扮演 提交于 2019-11-27 18:45:47
问题 I want to turn on Unknown Sources setting programmatically on non rooted device. I have checked with this code: boolean success; int result = Settings.Secure.getInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, 0); if (result == 0) { success = Settings.Secure.putString(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, "1"); } and with following permissions: <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android

Is it possible to run service in android platform continuously even after locking the device?

[亡魂溺海] 提交于 2019-11-27 18:36:18
问题 We have been working on developing service for android platform. In our service we need to send GPS data (Lat and Long) of device to some external REST service after every one minute. It is running fine for almost 15 minutes after locking of device. But after that it does not send any data. After unlocking the device, it start again to send data over REST service. My Code So far public class MainActivity extends AppCompatActivity { private PendingIntent pendingIntent; private PowerManager

Can anybody explain what is difference between unbound and bound service in android

被刻印的时光 ゝ 提交于 2019-11-27 18:33:14
Can anybody explain what is difference between unbound and bound service in android and explain about intent service Thanks Spurdow Bound Service A service is bound when an application component binds to it by calling bindService(). A bound service offers a client-server interface that allows components to interact with the service, send requests, get results, and even do so across processes with interprocess communication (IPC). When the last client unbinds from the service, the system destroys the service EXCEPT If the service was started by startService Unbound Service or Started A service

Android Activity with no GUI

空扰寡人 提交于 2019-11-27 18:22:09
I have created a activity that is only meant to be launched from a link (using a intent filter.) I do not want this activity to have a GUI - I just want it to start a service and put a notification in the bar. I have tried to put the intent filter for the link in my service, but that does not work. Is there a better thing to do this that will answer to intent filters - or can I just make my activity not have a GUI? Sorry if I'm being confusing, Isaac Reto Meier Your best bet would seem to be using a BroadcastReceiver . You can create a new BroadcastReceiver that listens for the Intent to

Constantly check for volume change in Android services

旧街凉风 提交于 2019-11-27 18:15:57
问题 I wrote this piece of code, it's obviously flawed. How do I go about creating a service which will constantly check for changes in volume? Key listeners cannot be used in services, please don't post an answer with volume key listeners. My code is wrong because I've given dummy condition for the while loop. What has to be the condition for my service to check for volume change and not crash? It can't be isScreenOn() because volume can be changed while listening to music and the screen is off.

Why Android service crashes with NullPointerException?

百般思念 提交于 2019-11-27 18:13:56
问题 Here is the code: public class BillingService extends Service implements ServiceConnection { ... @Override public void onStart(Intent intent, int startId) { handleCommand(intent, startId); // line 361 } /** * The {@link BillingReceiver} sends messages to this service using intents. * Each intent has an action and some extra arguments specific to that action. * @param intent the intent containing one of the supported actions * @param startId an identifier for the invocation instance of this

Asynctask vs Thread vs Services vs Loader

牧云@^-^@ 提交于 2019-11-27 17:43:13
I got slightly confused about the differences between Asynctask , Thread , Service , Loader in Android. I know how it works. But i still don't understand what and when should i use. I work with Android for 3 years, and generally still use AsyncTask for all background tasks (and sometimes Thread). But many people say that "Asynctask is outdated", and don't recommend to use them. Also they recommend to use robospice or Volley. So, is AsyncTask really so bad and i should use framework for networking tasks? And what should i use for background (not networking) task? humblerookie AysncTasks are not

Obtain Android GPS location once every few minutes

我怕爱的太早我们不能终老 提交于 2019-11-27 16:43:33
问题 I would like to write an app on Android to upload my GPS location to an external website once every ~5 minutes. This needs to have as minimal an impact on battery life as possible, but it also needs to work without any user interaction. (Background: I'm competing in an Ironman triathlon which will take me about 14 hours to complete, and want to broadcast my location in near-real-time but without having to worry about fiddling with my phone.) So my initial thought is to write a Service which

Dynamically register/unregister a broadcast receiver in android

一笑奈何 提交于 2019-11-27 16:40:06
问题 I want to dynamically register and unregister my receiver class with the broadcast: "android.net.wifi.STATE_CHANGE" This works very well if I do this in the manifest. But this makes it static. I want to do it dynamically in the activity class. What is its correspondent command in the activity class? This is what my code is... and I am getting a problem because of registering and unregistering(multiple times) my receiver(which is starting a service). public class startScreen extends Activity {

Android fullscreen app - prevent access to status bar

早过忘川 提交于 2019-11-27 16:20:33
I am creating a fullscreen app which will run in "kiosk" mode, so the user will not be able to exit. The app is defined as a launcher (home screen). The Activity in the manifest is defined with: android:theme="@android:style/Theme.NoTitleBar.Fullscreen" Additionally, the Activity ensures full screen mode with the following in its onCreate() : getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); However, it seems that the status bar is still accessible. It's hidden by default, but it can still be shown by