How to prevent Flurry change orientation of my activity? - android

One of my activities in my app has an android:screenOrientation="portrait" attribute in the manifest, as I don't want it to change orientation.
I'm trying to integrate Flurry like this:
in onStart:
FlurryAgent.onStartSession(this, "api_key");
FlurryAgent.initializeAds(this);
FrameLayout adsFrameLayout = (FrameLayout)findViewById(R.id.frameLayoutAdsContent);
FlurryAgent.getAd(this, "BannerTop-1", adsFrameLayout, FlurryAdSize.BANNER_BOTTOM, 0);
in inStop:
FlurryAgent.onEndSession(this);
and in the AndroidManifest.xml:
<activity
android:name="com.flurry.android.FlurryFullscreenTakeoverActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode"
android:screenOrientation="portrait" >
</activity>
What happens is that Flurry lets the activity to change orientation (when device is turned ti landscape). if I don't run the code in onStart the activity doesn't change its orientation.
thanks in advance,
Amitos80

What if you add: android:orientation="vertical" to the layout xml?

After a long research i found that this can't be done. flurry overrides my configuration and enables the screen to change orientation to landscape. if someone ever find a solution please share.

Related

Orientation Locking to landscape not working on emulator but on device

I have used following code in activity onCreate() to lock view only to landscape mode, it is perfectly working on device but not working on emulator, Since i dont have a device now it's hard to develop
code :
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
Please help
Try this:
android:screenOrientation="sensorLandscape"
Put this Code[Attribute] in Activity tag of AndroidManifest.xml file it should work.
In your manifest file simply add
<activity
android:name="yourActivity name"
android:screenOrientation="portrait" >
</activity>
Apologies if this is too obvious.. You have to manually put your emulator in landscape mode, I think. I think it's the F9 key, but it's been a while since I've done that.
Try this way, hope this will help you.
Define this attribute "android:screenOrientation="landscape"" as your activity in AndroidManifest.xml
Try this
Put below line of code in your manifest
<activity>
android:screenOrientation="landscape"
</activity>
It works for me....

Android orientation change even after locking it in system settings

as in the topic, ive got a trouble with locking screen orientation after its been locked in device's settings. Its a landscape app. Ive read couple threads about similar problem but havent got any revelant answer.
Thanks in advance
Mac
You can add android:screenOrientation="landscape" in your activity tag to specify the mode of screen orientation in your manifest file
<activity
android:name="com.xyz.myapp.SplashActivity"
android:label="#string/app_name"
android:screenOrientation="landscape" >
Hope it helps .
Add setRequestedOrientation in the onCreate method like below
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.homepage);
This would set to landscape if auto_rotate is off, otherwise if would rotate normally as long as it wasn't set to land/port in the manifest.
if(android.provider.Settings.System.getInt(getContentResolver(),Settings.System.ACCELEROMETER_ROTATION, 0) != 1){
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}

Locking orientation to portrait force close in my phone

I want my app to lock into portrait mode. For this I used this code :
<activity android:name="MyActivity"
android:label="#string/app_name" android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
>
and in MyActivity class :
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
This code work correctly in emulator, but when I install and run in my phone, the app is force closed.
How can I solve this problem?
Yo already use in manifest then there is no need to use by pragmatically. So remove the onConfigurationChanged method from your code.
I am using
android:screenOrientation="portrait"
in the manifest file, no other code in Java side and is working.
I see two problems here:
Remove android:configChanges="orientation|keyboardHidden" from manifest
Remove onConfigurationChanged from java
and it should work just fine

Get Locked Orientation

Is there a method to detect if the Auto-Rotation Lock of the device is on or off? My app needs to access that method to lock the orientation during runtime.
Add this in your Manifest file in your activity for the fixed orientation you want for your Activity
android:screenOrientation="portrait"
like
<activity android:name=".Settings" android:label="#string/app_name" android:screenOrientation="portrait">
or in java code you can use
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
In iPhone there is a method
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}
To unlock orientation. if u want to make it lock then change its value (YES to NO) where u want to lock orientation

Android error, failed to set top app changed

Can somebody please throw some light on the arcane error "Failed to
set top app changed", by the activity manager?
I'm wondering what causes this error. In one of my application I'm
making a view fullscreen and then switching back. For the first time
things are ok but then if i try to make the view full screen again, I
get a crash and the error mentioned above is found on logcat.
Any help is greatly appreciated.
Reagrds,
M
I just encountered this problem today myself.. let me tell you what did the trick for me... maybe it will help you too.
anyway in my case it crashed because i overrided onActivityResult and inside that event i tried to do this:
Bundle extra = data.getExtras();
String albumId = extra.getString("id");
this is old code that got left in the application.. after deleting this everything worked as expected.
hope this helps in some way.
I had the same problem with my app, the activity crashed and "activity manager: fail to set top app changed!" in logs. Turned out to be one line of code in the onPause caused the problem. Check your onPause method of the Activity that launches the new Activity to see if something should not be done there. I think there could be many reasons causing this problem, but the basic idea is that the launching activity does something wrong when the new Activity is going to show up.
My problem was that i change orientation on activity start and needed to add android:configChanges="orientation" , like this:
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
<activity
android:name=".RiskniMilionActivity"
android:label="#string/app_name"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Categories

Resources