int main(int argc, char* argv[]) {
int c = 0;
while(1) {
sleep(1);
LOGD("%d\n", c++);
}
return 0;
}
the code simply does counting and output to logcat.
It works well when I press HOME button to put to background, or resume to foreground. from logcat I can see "onPause", "onResume" messages shown as they should.
The problem is when I press POWER button, the program will output a "onDestroy" log to logcat, immediately after "nativePause" log. And then my program cannot receive messages any more, no matter I press HOME button or POWER button, or resume the program. But, it still counts and output numbers to logcat. It seems that only the Java thread dies, native C thread lives.
I am not sure whether this issue is caused by android version. My phone runs Android 4.1.1. In "project.properties" I set target=android-19 because my eclipse adt bundle (download from developer.android.com on November) supports minimum 19.
Any ideas? Thanks.
Did you specify in your AndroidManifest.xml that you are handling
orientation events? I had similar symptoms before I did that. Hearing
that the Java thread dies hints that it’s a Java-side problem. I think
some devices signal a change in orientation when they go to sleep.
Jonny D
On Mon, Dec 23, 2013 at 9:48 PM, RunningOn wrote:> Hi there. I am facing a problem about my SDL program run on Android. It
dies after pressing POWER button.
To test it, I simplified the code to below:
int main(int argc, char* argv[]) {
int c = 0;
while(1) {
sleep(1);
LOGD("%d\n", c++);
}
return 0;
}
the code simply does counting and output to logcat.
It works well when I press HOME button to put to background, or resume to
foreground. from logcat I can see “onPause”, “onResume” messages shown as
they should.
The problem is when I press POWER button, the program will output a
"onDestroy" log to logcat, immediately after “nativePause” log. And then my
program cannot receive messages any more, no matter I press HOME button or
POWER button, or resume the program. But, it still counts and output
numbers to logcat. It seems that only the Java thread dies, native C thread
lives.
I am not sure whether this issue is caused by android version. My phone
runs Android 4.1.1. In “project.properties” I set target=android-19 because
my eclipse adt bundle (download from developer.android.com on November)
supports minimum 19.
Any ideas? Thanks.
No I didn’t. That might be the issue. What exactly should I do? I am new to Android dev. Thanks
Jonny D wrote:> Did you specify in your AndroidManifest.xml that you are handling orientation events? ?I had similar symptoms before I did that. ?Hearing that the Java thread dies hints that it’s a Java-side problem. ?I think some devices signal a change in orientation when they go to sleep.
Jonny D
On Mon, Dec 23, 2013 at 9:48 PM, RunningOn <@RunningOn (@RunningOn)> wrote:
Hi there. I am facing a problem about my SDL program run on Android. It dies after pressing POWER button.
the code simply does counting and output to logcat.
It works well when I press HOME button to put to background, or resume to foreground. from logcat I can see “onPause”, “onResume” messages shown as they should.
The problem is when I press POWER button, the program will output a “onDestroy” log to logcat, immediately after “nativePause” log. And then my program cannot receive messages any more, no matter I press HOME button or POWER button, or resume the program. But, it still counts and output numbers to logcat. It seems that only the Java thread dies, native C thread lives.
I am not sure whether this issue is caused by android version. My phone runs Android 4.1.1. In “project.properties” I set target=android-19 because my eclipse adt bundle (download from developer.android.com (http://developer.android.com) on November) supports minimum 19.
Any ideas? Thanks.
I use these in my “activity” tag to specify that I’m handling orientation
events and to disable portrait orientation: android:configChanges=“
keyboardHidden|orientation” android:screenOrientation=“sensorLandscape”
Your needs may be different, but that should point you in the right
direction.
Jonny D
On Tue, Dec 24, 2013 at 8:02 PM, RunningOn wrote:> No I didn’t. That might be the issue. What exactly should I do? I am new
to Android dev. Thanks [image: Smile]
Jonny D wrote:
Did you specify in your AndroidManifest.xml that you are handling
orientation events? I had similar symptoms before I did that. Hearing
that the Java thread dies hints that it’s a Java-side problem. I think
some devices signal a change in orientation when they go to sleep.
Jonny D
On Mon, Dec 23, 2013 at 9:48 PM, RunningOn <> wrote:
Quote:
Hi there. I am facing a problem about my SDL program run on Android. It
dies after pressing POWER button.
To test it, I simplified the code to below:
int main(int argc, char* argv[]) {
int c = 0;
while(1) {
sleep(1);
LOGD("%d\n", c++);
}
return 0;
}
the code simply does counting and output to logcat.
It works well when I press HOME button to put to background, or resume to
foreground. from logcat I can see “onPause”, “onResume” messages shown as
they should.
The problem is when I press POWER button, the program will output a
"onDestroy" log to logcat, immediately after “nativePause” log. And then my
program cannot receive messages any more, no matter I press HOME button or
POWER button, or resume the program. But, it still counts and output
numbers to logcat. It seems that only the Java thread dies, native C thread
lives.
I am not sure whether this issue is caused by android version. My phone
runs Android 4.1.1. In “project.properties” I set target=android-19 because
my eclipse adt bundle (download from developer.android.com on November)
supports minimum 19.
Any ideas? Thanks.
Problem solved by adding your config to my AndroidManifest.xml.
Thank you very much
Jonny D wrote:> I use these in my “activity” tag to specify that I’m handling orientation events and to disable portrait?orientation: android:configChanges=“keyboardHidden|orientation” android:screenOrientation=“sensorLandscape”
Your needs may be different, but that should point you in the right direction.
On Tue, Dec 24, 2013 at 10:08 PM, RunningOn wrote:> Problem solved by adding your config to my AndroidManifest.xml.
Thank you very much [image: Smile]
Jonny D wrote:
I use these in my “activity” tag to specify that I’m handling
orientation events and to disable portrait orientation:
android:configChanges="keyboardHidden|orientation"
android:screenOrientation=“sensorLandscape”
Your needs may be different, but that should point you in the right
direction.