preferenceScreen - <意向... /> - 例外 - FLAG_ACTIVITY_NEW_TASK [英] PreferenceScreen - <intent .../> - Exception - FLAG_ACTIVITY_NEW_TASK

查看:288
本文介绍了preferenceScreen - <意向... /> - 例外 - FLAG_ACTIVITY_NEW_TASK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的Andr​​oid的发展。

I am new at android developing.

该项目即将实施的AbstractAccountAuthenticator与AbstractThreadedSyncAdapter同步与内容供应商的服务器上的特定数据。

The project is about implementing an AbstractAccountAuthenticator with an AbstractThreadedSyncAdapter to sync certain data on a server with a content provider.

我做的一切,既增加账户和同步是没有任何问题运行。

I made everything and both adding accounts and syncing is running without any problems.

现在我已经尝试添加preference屏幕仿如建议在android参考通过XML(搜索AbstractAccountAuthenticator,它是有解释)是这样的:

Now I've tried to add a Preference-Screen just like suggested in the android reference (search for AbstractAccountAuthenticator, it is explained there) via xml like this:

autenticator.xml:

<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
    android:accountType="typeOfAuthenticator"
    android:icon="@drawable/icon"
    android:smallIcon="@drawable/miniIcon"
    android:label="@string/label"
    android:accountPreferences="@xml/account_preferences"
 />

在preference屏幕-XML看​​起来是这样的:

The Preference-Screen-xml looks like this:

account_ preferences.xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 <PreferenceCategory android:title="@string/pref_cat_general">
  <PreferenceScreen android:key="@string/pref_cat_scr_keygen" android:title="@string/pref_cat_scr_keygen_title" android:summary="@string/pref_cat_scr_keygen_summary">
   <intent android:action="android.intent.action.VIEW" android:targetPackage="com.android.clean" android:targetClass="com.android.clean.KeygenAct" />
  </PreferenceScreen>
 </PreferenceCategory>
</PreferenceScreen>

该屏幕promted应该的,但是,这就是问题:当我点击了preferenceScreen它导致系统崩溃的意图(无论是在模拟器和我的HTC-欲望) 。

The screen is promted how it should be, but and that is the problem: When I click on the PreferenceScreen with the intent it leads to a crash of the system (both in the emulator and my HTC-Desire).

LogCat中说:

ERROR / AndroidRuntime(18754):   android.util.AndroidRuntimeException:   调用startActivity()禁区外   一个活动的情况下需要   FLAG_ACTIVITY_NEW_TASK标志。这是   真的是你想要的吗?

ERROR/AndroidRuntime(18754): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

(全 LogCat中的引擎收录

清单,其中活性被定义的下面的部分:

Here the part of the manifest, where the activity is defined:

<activity android:name=".KeygenAct">
    <intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

整个测试 - code(这是我的项目的要领来发现问题)被发现在谷歌code(HTTP://$c$c.google.com/p/cleanproject /来源/浏览/)(Eclipse的项目)

The whole test-code (it is my project on the essentials to find the problem) is to find at googlecode (http://code.google.com/p/cleanproject/source/browse/) (Eclipse-Project)

感谢你已经为你的帮助, Esentian

Thank you already for your help, Esentian

PS:凯基是不是一个密钥发生器,它意味着更多key_general。有点inartfully EX pressed;)

p.s.: keygen is not a key generator, it means more key_general. A bit inartfully expressed ;)

推荐答案

我有同样的问题,刚刚发现,如果你改变了preferences为:

i had the same problem and have just found out, that if you change your preferences to:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 <PreferenceCategory android:title="@string/pref_cat_general">
 </PreferenceCategory>
  <PreferenceScreen android:key="@string/pref_cat_scr_keygen" android:title="@string/pref_cat_scr_keygen_title" android:summary="@string/pref_cat_scr_keygen_summary">
   <intent android:action="android.intent.action.VIEW" android:targetPackage="com.android.clean" android:targetClass="com.android.clean.KeygenAct" />
  </PreferenceScreen>
</PreferenceScreen>

然后按预期工作。这是奇怪,因为我希望preferenceCategory组项目作为其子......为什么它会如此不相关的(?)错误造成的?

Then it works as expected. This is weird because I would expect PreferenceCategory to group items as its children... And why does it result with such unrelated (?) error?

这篇关于preferenceScreen - &LT;意向... /&GT; - 例外 - FLAG_ACTIVITY_NEW_TASK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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