就是添加个notification就可以。
详情参考apidemos
详情参考apidemos
解决方案 »
- 如何解决: E/AndroidRuntime(1459): java.lang.ArrayIndexOutOfBoundsExcep
- android里关于activity切换的问题
- 添加9patch图片后,工程中莫名其妙的多了很多错误
- 怎样把android工程的资源图片分目录管理?
- 如何傳遞實時影像(視頻)串流到伺服器
- Android开发论坛上线了,专为开发者提供的社区!
- (求助)本地Android源码与网上他人文章所述不一样
- 关于加速度计的值 怎么存储
- 打开eclipse后有很多端口自动forward
- 能不能找个学生帮忙解答问题?
- android项目Eclipse报错
- 请问这个引入怎么解决。急---急!
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, SayHello.class), Intent.FLAG_ACTIVITY_NEW_TASK); // The ticker text, this uses a formatted string so our message could be
// localized
String tickerText = getString(R.string.imcoming_message_ticker_text,
message); // construct the Notification object.
Notification notif = new Notification(R.drawable.icon, tickerText,
System.currentTimeMillis()); // Set the info for the views that show in the notification panel.
notif.setLatestEventInfo(this, from, message, contentIntent);但是每次new Intent(this, SayHello.class)会新建一个activity,同一个页面有两个。
怎么才能在点击通知图标,切换到前台后,只显示原来的主界面呢?
而不是重新创建一个主界面。
通过在androidManifest写入一个
<receiver android:name=".BootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
可以实现开机自动登录。
但通过程序的方式取消开机自动登录呢,在程序中可以在androidManifest中添加/删除属性吗?
今天没分了,还望过路英雄指点一下
然后设置那个activity是single task的
我已经给出解决方案了,可能不是太好!难道不是同一个人?
设置Intent.FLAG_ACTIVITY_NEW_TASK,打开notification确实还会新建一个activity
可以这样,把notification的跳转指向一个activity,这个activity什么也不做,在oncreate里面写一个finish();这样就OK了
而在程序中手工注册广播。可以否??
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if (intent.getAction().equals(ACTION))
{
if(ConfigManager.Instance(context).loadBoolean("runAuto")) {
Intent sayHelloIntent = new Intent(context, ChannelMainActivity.class);
sayHelloIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(sayHelloIntent);
}
}
}