是否可以在主屏幕上显示任何类型的通知(来自我的应用程序)?
提前致谢!
我已经为我的设备实现了通知.
它很棒.但是,如果我重新启动设备,它根本不会工作.
那有什么不对吗?我应该在清单中添加anithing吗?
我已添加此代码以接收通知类的广播.
码:
<!-- To receive the Alarm Notification -->
<receiver android:name=".AlarmNotificationReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"></action>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
谢谢.
notifications android push-notification android-manifest android-notifications
编辑:请注意:我完全重新解释了我的问题.
我的应用程序有两个Activites:一个和乙.Activity A是MAIN.因此,应用程序启动,屏幕上出现A. 用户按下按钮,屏幕上出现新的Activity B.
所以,现在有在我的"回栈" 2个活动:一个和乙.
现在我按"Home"键,然后点击我的应用程序在启动器上的图标:Activity B出现在屏幕上(而不是A),只要它是我的任务中的顶级活动.
现在问:我怎样才能Intent同样打开目前最重要Activity的任务?
我需要它用于Notification:当用户点击我的时Notification,Activity此任务的顶部应出现在屏幕上,而不是指定的任务.
我尝试了许多Intent标志,比如SINGLE_TOP和其他标志,但我仍然无法得到我需要的东西.
有谁知道解决方案?
几天前我发布了我的应用程序的新版本2.2.然后我发现了一些小错误,并希望将固定版本上传到Market.但是这些错误并不重要,我不想惹恼那些已经下载了2.2版本并通知新版本的用户.
有没有办法做到这一点?
以下代码必须在设置时间(单击按钮)10000毫秒后启动报警..但是AlarmManager单击按钮后立即启动服务原因?package pit.opensource.notificationapp;
import java.util.Calendar;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class NotificationAppActivity extends Activity {
private PendingIntent pendingIntent;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonStart = (Button)findViewById(R.id.btnset);
buttonStart.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
setAlarm();
//setAlarm(25);
}});
}
void setAlarm(){
Intent myIntent = new Intent(NotificationAppActivity.this, ShowNotification.class);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
pendingIntent = PendingIntent.getService(NotificationAppActivity.this, …Run Code Online (Sandbox Code Playgroud) service notifications android alarmmanager android-pendingintent
现在我对我的主要活动发出警报,启动了一个在状态栏上启动通知的类.当我点击通知时,它会打开我的主要活动,现在我希望它在该活动中打开一个特定的视图.
这是我的通知代码.
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
int icon = android.R.drawable.stat_notify_chat; // icon from resources
CharSequence tickerText = "TickerText"; // ticker-text
long when = System.currentTimeMillis(); // notification time
CharSequence contentTitle = "My notification"; // message title
CharSequence contentText = "Hello World!"; // message text
//This is the intent to open my main activity when the notification is clicked
final Intent notificationIntent = new Intent(context, mainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
// the next two …Run Code Online (Sandbox Code Playgroud) 嗨,在我的应用程序中,当我从服务器收到推送通知时,我的应用程序徽章增加了一个.当我打开应用程序并关闭它没有得到reduce.so我的问题是当用户看到通知时如何减少应用程序图标上的徽章图标
我最近发现了有关ActiveSupport :: Notifications的信息.我认为这是一个监控应用程序的好工具.
我目前正在Rails之外使用它来监控我的Sinatra应用程序,它运行良好.
但是我经常使用它来检测自定义查询,并希望以某种方式通知查询结果:
my_input = "some_query"
ActiveSupport::Notifications.instrument("myapp.create", :input => my_input) do
#stuff
result = search_for my_input
#stuff
result
end
Run Code Online (Sandbox Code Playgroud)
现在我可以订阅它并且还可以获得已执行的查询(在有效负载哈希中可用).但我也希望在订阅者中看到结果.
那么有没有办法在执行块时向有效负载添加任何自定义值?
我正在开发一个Android应用程序.该应用程序就像本机短信应用程序.我在通知部分遇到问题.在本机应用程序中,他们以下列方式处理通知.
1)如果来自特定号码的消息,则点击通知将导致相应联系人的聊天页面,并且通知将被清除.
2)如果来自不同号码的消息,则点击通知将导致主页和通知不会清除.
我完成了第一部分,我不知道第二部分.有没有办法让通知部分没有明确并调用意图.
如何检查应用程序是否已连接到互联网?目前,我在我的appdelegate.m文件中使用此代码
dispatch_queue_t connectivityThread = dispatch_queue_create("com.gm.kart.connectivity", NULL);
dispatch_async(connectivityThread, ^{
while (true){
if([GMMConnectivity hasConnectivity])
NSLog(@"%@", @"connected");
else
NSLog(@"Not connected");
usleep(10000000);
}
});
Run Code Online (Sandbox Code Playgroud)
当我点击我的登录按钮时,我想检查互联网是否已连接NSnotificationcenter?
请帮我
notifications ×10
android ×7
ios ×2
alarmmanager ×1
google-play ×1
homescreen ×1
iphone ×1
java ×1
notify ×1
objective-c ×1
push ×1
ruby ×1
service ×1