Android screen orientation intent

不打扰是莪最后的温柔 提交于 2019-12-12 00:26:07

问题


My Android app is configured to work on landscape mode only, so I want to make e-mail client, which is created by intent from my app, be landscape too. Is it possible?

Here is my code:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/xml");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"example@mail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
i.putExtra(Intent.EXTRA_TEXT, "");
try {
    Intent chooser_intent = Intent.createChooser(i, "Send e-mail");  
    startActivity(chooser_intent);
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(getApplicationContext(), "E-mail client not found", Toast.LENGTH_LONG).show();
}

回答1:


It is not possible to specify the orientation of an Activity, if it is external to your app. If an Activity is local to your app (ie. defined in your own Manifest file) - then you could specify the orientation there.

Bottom line, you can not control the orientation of an Application that is not your own (ie. called via system Intent).




回答2:


in android manifest add this android:screenOrientation="landscape" in activity.

example:

 <activity android:name=".yourClientAddressActivity" android:screenOrientation="landscape"></activity>



回答3:


If the screen device is already in the landscape orientation, then the new email activity should use it if it supports it; otherwise, it will go into the portrait mode but then, you can't do anything about that because it doesn't support the landscape orientation in the first place.



来源:https://stackoverflow.com/questions/14070375/android-screen-orientation-intent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!