【问题标题】:Getting Push Notification in android using sqlite database使用sqlite数据库在android中获取推送通知
【发布时间】:2014-05-25 02:13:37
【问题描述】:

如何在使用钛的 Android 系统中以推送通知的形式在上午 8:00 接收消息?该消息已存储在 SQLite 数据库中。

【问题讨论】:

  • 你能解释一下你想要什么吗...?
  • 你在说Local Notification吗?
  • @Krunal Indrodiya 实际上,我的数据库中有几次按摩,我希望每天在特定时间按顺序进行一次按摩作为推送通知。
  • @Simple Plan 是的,我想要本地通知。
  • 此链接可能对您有所帮助。 developer.android.com/guide/topics/ui/notifiers/…

标签: android sqlite push-notification titanium


【解决方案1】:

试试这个模块来获取本地通知。

https://github.com/benbahrenburg/benCoding.AlarmManager

【讨论】:

    【解决方案2】:

    从 db 获取您的消息并通知

    import android.os.Bundle;
    import android.annotation.SuppressLint;
    import android.app.Activity;
     import android.app.Notification;
    import android.app.NotificationManager;
    import android.app.PendingIntent;
    import android.content.Intent;
    import android.view.Menu;
    
    public class MainActivity extends Activity {
    
    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        showNotification("This is My Text");
    
    }
    private void showNotification(String message) {
        // In this sample, we'll use the same text for the ticker and the expanded notification
        CharSequence text =message;
    
        // Set the icon, scrolling text and timestamp
        Notification notification = new Notification(R.drawable.ic_launcher, text,
                System.currentTimeMillis());
    
        // The PendingIntent to launch our activity if the user selects this notification
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                new Intent(this, MainActivity.class), 0);
        //  PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(),0,
        //      new Intent(),PendingIntent.FLAG_UPDATE_CURRENT);
    
        // Set the info for the views that show in the notification panel.
        notification.setLatestEventInfo(this, message,
                       text, contentIntent);
         NotificationManager mNM;
         mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
         int NOTIFICATION = 0;
         // Send the notification.
        mNM.notify(NOTIFICATION, notification);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
     }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多