有没有"&的onCreate QUOT;方法为Android窗口小部件? [英] is there any "onCreate" method for Android widgets?
问题描述
我在下面的本教程中添加EULA我的Android应用程序,但我有两个问题:
1)我的应用程序是基于小窗口,我想尽快部件开始显示我的EULA。是否有任何部件的onCreate的方法?
2)如果用户拒绝EULA,我想结束我的应用程序。我是C#程序员,所以我不知道是否有针对Android应用的退出()方法。如何强行关闭我的应用程序,而无需用户的行为?
I'm following this tutorial for adding EULA to my Android application, but i have two problems: 1) My app is based on widget and i would like to show my EULA as soon as widget is started. Is there any "onCreate" method for widgets? 2) If user refuse EULA, i would like to close my app. I'm C# programmer, so i don't know if there's any "Exit()" method for Android apps. How to forcefully close my app without user's action?
推荐答案
有没有一个的onCreate()
本身,但有一种方式来显示活动当第一次添加小部件。这样做的一种方式是以下
There isn't an onCreate()
per se, but there is a way to show an activity when your widget is first added. One way of doing this is the following.
在您的AppWidget提供商的XML文件一定要添加为 appwidget提供商
的属性:
In your AppWidget provider XML file be sure to add as a property of appwidget-provider
:
android:configure="your.eula.activity"
和不要忘了申报 your.eula.activity
在的AndroidManifest.xml
<activity android:name="your.eula.activity">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
</activity>
而在 your.eula.activity
的的onCreate()
你应该叫
setResult(RESULT_CANCELED);
finish();
这篇关于有没有&QUOT;&的onCreate QUOT;方法为Android窗口小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!