Android SDK, second activty java/xml causing app to crash - java

I have an app with several activities in it. And had to change some of the flow within the pages. To do this I created a flyout side menu. The flyout menu works on its own . But when added to the main app it causes the whole app to crash.
So I will be on the main screen and click to go to the activity that has the flyout in it. And the app crashes between the 2 activities. Get and error say that there is something wrong with the onCreate().
this.root = (FlyOutContainer) this.getLayoutInflater().inflate(R.layout.activity_main, null);
Just to help give a little more info. I am creating an app with a flyout menu that should allow me to click on various buttons and go to new activities. But I can not even get to the activiity that has the menu in it. And not sure how to switch between various activities.

Related

How to open little popup menu for selecting wifi in android?

I noticed this half screen wifi selection menu in some Android Apps.
I would like to use this menu in my own app, to give the user the possibility to select the wifi without jumping to settings app.
I didn't find any instruction how to do this. However AndroidStudios Layout Inspector showed me that its belonging to the system, not to the app.
Anyone knows how to open this menu ?
It's called a Settings Panel:
https://medium.com/google-developer-experts/exploring-android-q-settings-panels-d308525b8345
You are looking for Settings Panel
This is for Android Q.
Here's an example to how to call it.
startActivityForResult(Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY), INTERNET_SETTINGS_REQUEST)

After Home button pressed, my Activity not reload when launch it again from click icon app

My activity UI have a CheckBox which set default check is "unchecked".
I have a receiver to listen when a new incoming SMS, then the checkBox will be set "checked".
And this is my steps:
Open activity for first time.
Press Home button to let my app to background
From another phone, send a SMS to my phone.
Launch app again by click icon app
Result : The CheckBox still is uncheck. (It means my activity not reload yet)
I try to long press Home button and then remove my app from the list app, then launch app again by click icon app, after that the CheckBox is checked.
Can anybody help me explain for this ?
And how can I reload my activity without removing app from list background apps ?
Thanks
It seems some UI reloading is happening inside onCreate(). Instead do it in onResume() to update the view when user is opening the app from background.
If you remove the app from background and then start it, it will call onCreate. However if you just come back from background onResume is called but not onCreate.
Try sharing code while asking questions.
Meanwhile do read about activity life cycle.After that check where you have implemented code to enable check option and see if it is getting called while coming back to application. It is probably not getting called and that is where the issue is.
In your receiver listener save a variable in the shared preferences to indicate the state of the checkbox. Then in your on onCreate() activity grab the state from the shared preferences and update the ui accordingly.

Widget configuration

My application is fitted with widgets. When the user puts a new widget on it's screen, I want it to be configured. So far, everything is fine : my configuration app is correctly launched, and executed with no error. The problem is that the widget doesn't appear on the screen and instead of staying in the home screen with the new widget displayed on it, the screen goes back to the list of the available widgets.
As indicated in the developer's guide, in the configuration Activity, I update my widget in the same way I do it in my AppWidgetProvider, and it used to work before I add the configuration Activity.
I am certainly missing something. Can anyone tell me what it is?
Are you calling setResult(RESULT_OK) and also providing a result Intent with the appwidget ID as an extra? See step 5 here: Updating the App Widget from the configuration Activity

Tab problems in Android/Eclipse

I am new to android development/eclipse and have run into a problem. I have 3 working apps that I programmed that work by themselves. One of these is a app that simply displays 2 tabs that when clicked don't really do anything. What I need to do is integrate my three programs together so that when you click on the tabs they start the other 2 apps. My biggest problem right now is the layout. I have them all together and compiled with no errors, but when I run it everything is displayed with the tabs and its a mess. My question is, how can I make it so that only the right stuff displays only when a tab is clicked. My xml file is a jumbled mess with like three different LinearLayouts. I am so new I don't know where to start. Any help would be greatly appreciated!
Brian
What is displayed on the screen at one time is called an Activity. Looks like you want 3 activities, but what you have is only one Main Activity. You should display the 2 tabs on the Main Activity and then use an Intent to change between activities, when you press on the tabs.
For a reference, you can refer to the android developer site: http://developer.android.com/training/basics/firstapp/starting-activity.html
I hope this helps!

Android multitasking problem

I have an android application which main view consists of a tab-bar with three tabs in it.
When developing and running the application on the device through adb I get the following behavior:
When clicking the phone button "Home screen" and relaunching the application it seems as the application continues where I was before pressing the button (remembers selected tab etc...) (apparently its still running in the background).
However when I export and sign the application (using Eclipse) it suddenly always seem to start a new instance of the application when returning from home screen.
Why does it behave so different in those cases? And what do I need to do in my application in order to always have the "running in background" behavior.
If you always want your application to have "running in background behavior", then set android:alwaysRetainTaskState="true" in your main activity manifest. This prevents Android from periodically resetting your application back to the root activity.
android:alwaysRetainTaskState
It sounds as though your application is being destroyed between the point that you go to the home screen and start the app back up again. This can be due to not having enough memory available on the device. If you have a lot of background apps running on your device this may be the reason it is happening.
I would recommend debugging and checking out which path is being hit, that is, whether or not your app is going through just the onResume lifecycle method, or if it is also going through the onCreate lifecycle method.

Categories

Resources