Denys Nikolayenko
Denys Nikolayenko

Reputation: 568

How to open another activity with the desired screen orientation?

I need to preview PDF file, but run viewer in a landscape fixed mode. Here is my current source code:

Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

Is there a way to say it should view it in landscape mode ? Thanks in advance!

EIDT: PDF viewer is 3rd party app

Upvotes: 0

Views: 1198

Answers (2)

Kurru
Kurru

Reputation: 14321

I believe you can do this by setting in your manifest on the activity you want to be in landscape mode

android:screenOrientation="landscape"

This only works for Activities you control

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006614

Tell the user to turn their phone.

Each application determines on its own how to handle screen orientation. You have no ability to override how other applications behave, any more than they have the ability to override how you behave.

EDIT: To clarify, this assumes that you are trying to open a third-party PDF viewer. @Kurru's answer is correct for activities of your own that you write.

Upvotes: 4

Related Questions