version 1.0
If you want to try and work out what the problem is, I'd suggest changing the sqlite3_exec method (for example, replacing the closing parentheses with parentheses, commas, or semi-colons) in your example code and trying again.
Q:
Wake up on user action
I would like to create a simple tool that wakes up my application on user action.
I am aware of the AlarmManager, which is used to trigger an action at a specific time.
However, I want to be able to show a dialog box if an user has not touched the phone after a specific amount of time (which I am planning to use SharedPreferences for).
How would I implement this?
A:
You would want to use WakefulBroadcastReceiver. The idea of this class is that you write an ActionReceiver to do what you want, and once you wake your process, you broadcast a wakeful Intent to all the registered receivers in your application. If the receiver is active, then it executes your custom code. If the receiver is not active, then you ignore it and don't bother waking it.
See the documentation for the WakefulIntentService class, which is the main class for this class.
If you are using the support library, I'd recommend WakefulLibraray, a small wrapper library that makes this a little easier to use.
Here's an example:
public class ExampleReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(YourCustomAction)) {
// Do some stuff
}
}
}
Then you can register it in your manifest file, like this:
I use the following code to start a service when I
Related links:
コメント