android-activity

Pressing Back Button did not go back to previous activity Android

亡梦爱人 提交于 2020-01-04 18:52:27
问题 I was reading through a lot of topics today regarding this. However, all the solutions that I had seen, failed to be a solution for me. I am new in Android development. My problem is that I had two buttons in my main page - namely PlayGame and Help. The PlayGame onClicked() will direct the user to the "difficulty page" where the user can choose Easy, Medium or Hard mode. What I want is that when the user pressed the Android back button in the "difficulty page", it will go back to the main

Why does my Android Activity close when AdMob loads an ad?

别来无恙 提交于 2020-01-04 15:27:08
问题 I've been putting AdMob ads in an otherwise working Android app, following the instructions here. The app has 2 activities. One of them is only reachable from the first. I'm currently adding ads to this second activity. I've tried both creating an AdView programmatically in the onCreate method and adding appropriate code to the XML layout file for the Activity. In both cases the activity will exit the second Activity and go to the first as if the back button had been pressed as soon as it

Coming back to an Activity after making a phone call

依然范特西╮ 提交于 2020-01-04 13:27:45
问题 I want to make a phone call and after the call ends I want to come back the Activity which started a call. Code to start a call : // Start a call Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + phoneNumber)); startActivity(callIntent); Code to handle coming back to activity : // Monitor phone call activities private class PhoneCallListener extends PhoneStateListener { private boolean isPhoneCalling = false; String TAG = "PhoneCallListener"; @Override

Coming back to an Activity after making a phone call

余生颓废 提交于 2020-01-04 13:27:01
问题 I want to make a phone call and after the call ends I want to come back the Activity which started a call. Code to start a call : // Start a call Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + phoneNumber)); startActivity(callIntent); Code to handle coming back to activity : // Monitor phone call activities private class PhoneCallListener extends PhoneStateListener { private boolean isPhoneCalling = false; String TAG = "PhoneCallListener"; @Override

Coming back to an Activity after making a phone call

雨燕双飞 提交于 2020-01-04 13:26:55
问题 I want to make a phone call and after the call ends I want to come back the Activity which started a call. Code to start a call : // Start a call Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + phoneNumber)); startActivity(callIntent); Code to handle coming back to activity : // Monitor phone call activities private class PhoneCallListener extends PhoneStateListener { private boolean isPhoneCalling = false; String TAG = "PhoneCallListener"; @Override

Starting Activity when video is finished playing

六眼飞鱼酱① 提交于 2020-01-04 11:11:13
问题 In my Android app, I am trying to simply go back to my main Activity once a video that I am playing ends. I have tried many workarounds, but I can't find a way to call StartActivity from the video onCompletionListener - I am getting the "cannot make a static reference to the non-static method startActivity(Intent) from the type Activity" error. I tried getting a context from the Activity that preceded the videoView, and passing that to the intent/startActivity. That allowed the app to compile

Android: Pause and resume a thread within an activity

落爺英雄遲暮 提交于 2020-01-04 09:14:13
问题 EDIT: I've found that what I'm describing below only occurs on my emulated device (Nexus 5, target api 19, 4.4.2 with Intel Atom (x86) cpu), but NOT on my physical device (HTC One).... EDIT2: Edit1 was due to an IllegalStateException that I didnt catch. Added some code to check if the thread was already running before trying to start it. This combined with the accepted answer resolved my issue. I have implemented an activty that starts a new thread in the activity's onCreate method, like this

Android: Wakelock & handling orientation change

你说的曾经没有我的故事 提交于 2020-01-04 09:10:13
问题 I'm using Wakelock in my application to prevent the phone from sleeping when the app is visible. The problem comes when there is an orientation change and the system destroys and re-creates the app in landscape mode. If the wakelock timer has expired in the background the system takes the release of wakelock as an opportunity to switch off the screen. Edit: I should mention that I am setting Wakelock onResume, and releasing onPause - as I understand it, it's necessary to release then to

Android: Wakelock & handling orientation change

左心房为你撑大大i 提交于 2020-01-04 09:09:50
问题 I'm using Wakelock in my application to prevent the phone from sleeping when the app is visible. The problem comes when there is an orientation change and the system destroys and re-creates the app in landscape mode. If the wakelock timer has expired in the background the system takes the release of wakelock as an opportunity to switch off the screen. Edit: I should mention that I am setting Wakelock onResume, and releasing onPause - as I understand it, it's necessary to release then to

How do I create a popup overlay view in an activity without Fragment?

北城余情 提交于 2020-01-04 09:06:09
问题 I'd like to show when pressed a button a popup onto my Activity. I was inspired by this question So I use the "merge" control in the content xml of the activity and put in it the 2 different Layouts, the problem occurs obviously at this line (code taken from the question linked above): FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .add(R.id.overlay_fragment_container, yourFragment) .commit(); because ofc FragmentManager works for Fragments. My