推出的Widget应用程序的第二个实例 [英] Widget launching a second instance of application

查看:111
本文介绍了推出的Widget应用程序的第二个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,当它被点击后,从我的窗口小部件启动我的应用程序的问题。
下面是一些code的切

I am having problems launching my application from my widget when it's clicked upon. Here is a cut of some code

// Create an Intent to launch activity
Intent intent = new Intent(context, Entry_MainTabView.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);             
updateViews.setOnClickPendingIntent(R.id.Widget, pendingIntent);

现在采取的方案​​。
我启动我的应用程序,退出到首页,然后点击我的小部件。
它启动该应用程序的第二个实例,所以当我点击后退,应用程序消失并显示其他副本。我还是那句话打回,最后再回到主屏幕。

Now take the scenario. I launch my app, exit to the home page , then click on my widget. It launches a second instance of the application, so when I hit "back" , the application goes away and reveals the other copy. I then hit back again and finally go back to the homescreen.

我怎样才能让意图只有在没有在RAM中已经存在创建一个新的实例?

How can I make the Intent only create a new instance if none already exists in ram ?

推荐答案

你有没有看 singleInstance和singleTask活动的启动模式? <一href=\"http://books.google.com.au/books?id=Bam8K5SIiTkC&pg=PA465&lpg=PA465&dq=android+widget+single+instance&source=bl&ots=NGIiz5HSW1&sig=aMRdWPOZkprh6SbH3KBB-SRRFUg&hl=en&ei=WsD6TOayBYbsrAfY3c2FCA&sa=X&oi=book_result&ct=result&resnum=4&ved=0CCYQ6AEwAzgK#v=onepage&q=android%20widget%20single%20instance&f=false\"相对=nofollow>此摘录临Android的2 表示有确保只有一个小部件的运行实例没有任何记载的方法。

Have you looked at singleInstance and singleTask launch modes of an activity? This extract from Pro Android 2 indicates that there is no documented way of ensuring that there is only one instance of the widget running.

这篇关于推出的Widget应用程序的第二个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆