我一直在搜索它,但我没有得到任何有用的信息。
SQLite
获取Database
的数据。 我不知道该怎么做。我已经google了很多但是没有任何想法或解决方案。
如果您有任何建议请帮助我,请建议我任何链接或其他教程等,
提前致谢。
答案 0 :(得分:1)
如果您创建任何行程,请将该信息保存在服务器端数据库中。
在您的应用中,您需要BroadcastReceiver
来检测用户现在是否已连接到互联网。然后创建一个服务器request
并获取您最近创建的行程信息作为响应。 Internet Connection Detection code link
将用户设备本地信息保存在SQLite
数据库中。
现在,您必须使用AlarmManager
默认情况下在特定时间内显示通知或用户设置时间。
Alarm Example
您将在BroadcastReceiver
中显示声音播放地点的通知。
通知代码。
private void showNotification(Context context){
//Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
//v.vibrate(500);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
//Setting icon, title, message
mBuilder.setSmallIcon(R.drawable.notification);
mBuilder.setContentTitle("data form sqlite");
mBuilder.setContentText("data form sqlite.");
//Setting sound
Uri alarmSound = Uri.fromFile(new File("file:///android_asset/noficicatin.mp3"));//RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
mBuilder.setSound(alarmSound);
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(new File("file:///android_asset/noficicatin.mp3").getAbsolutePath());
mp.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//mBuilder.setAutoCancel(true);
//Setting Vibratortion
long[] pattern = {500,500,500,500,500,500,500,500};
mBuilder.setVibrate(pattern);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(notificationID, mBuilder.build());
}
我希望你知道show create server request,get response和SQLite database use。祝你好运。