McP*_*McP 2 resources parsing android manifest setorientation
尝试使用字符串限定符在清单文件中设置方向
android:screenOrientation="@string/orientation"
Run Code Online (Sandbox Code Playgroud)
适用于4.0 asus平板电脑,但在2.1野火和4.1 Galaxy S上都失败了.问题实际上是链接到资源,如果输入肖像,则可以使用.
我试过更改平板电脑中使用的限定符来测试手机.这意味着所有设备都使用完全相同的代码,资源和布局.所以它不能拼写错误或构建问题.但它仍然在手机而不是平板电脑上失败了.这似乎是android中的另一个错误.
给出下面的错误,logcat中没有任何内容
Installation error: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION
Please check logcat output for more details.
Launch canceled!
Run Code Online (Sandbox Code Playgroud)
清单部分
<activity
android:name=".MainActivity"
android:screenOrientation="@string/orientation"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我知道我可以以编程方式完成.但这是野火的另一个问题,而不是立即重启.相反,它等待视图设置等.这在其他设备中不会发生.
谷歌搜索并发现其他一些人使用这些方法,但他们似乎没有发现任何问题. http://capdroid.wordpress.com/2012/07/21/different-screen-orientation-on-different-screen-size
谢谢
小智 5
我有同样的问题,我使用整数值而不是字符串值解决了它,并在"onCreate"方法中设置方向:
例:
值/ strings.xml中
<resources>
<integer name="orientation">1</integer>
...
Run Code Online (Sandbox Code Playgroud)
值-sw600dp/strings.xml中
<resources>
<integer name="orientation">0</integer>
</resources>
Run Code Online (Sandbox Code Playgroud)
然后,在你的onCreate:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRequestedOrientation(getResources().getInteger(R.integer.orientation));
Run Code Online (Sandbox Code Playgroud)
每个方向都有一个整数值,有关详细信息,请参阅此页面:http://developer.android.com/reference/android/R.attr.html#screenOrientation