Widget configuration - java

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

Related

Android autolink links always start browser

I'm working on an Android application with an activity dedicated to a webview. I also have a chat section of the app that autolinks web links in the messages. I've created a onItemClick listener on the chat messages to start the webview activity. This listener works when I click the whole chat bubble, but I noticed that if I only click the highlighted link in the message, the listener isn't called and instead my default browser is loaded up.
I put a log message in front of every instance of an intent with ACTION_VIEW, thinking that some other part of my app may be launching the browser, but it doesn't seem like this is the case.
I'm wondering if android has any default methods that catch autolink urls and starts the browser that I could override. Otherwise, I was thinking that I could turn off autolink and imitate the appearance of links with the blue text and the underline, but this seems like a poor solution.
Thanks ahead for any tips on how Android works!
I encountered this situation too, where I have autolink set up in TextViews to automatically handle URLs in TextViews. However, the default behavior is to open the web page in an external browser, so how do we make it open in a webview activity (for example)?
Beneath the hood, this is handled for TextView by LinkMovementMethod. However, the behavior is difficult to customize. There is a 3rd party enhancement over LinkMovementMethod, known as BetterLinkMovementMethod, described in more detail in this blog post. With just a few lines of code changes, the TextView autolinks can be made to open in your webview activity (and clearly, all kinds of other behaviors can be customized as desired).

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

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.

Android Studio, creating any new activity now defaults to nothing and does not create a content.xml

I am a noob to Android Studio, I started a project and everything was going fine. Any time I created a new activity I would have a default screen with a toolbar at the top and an email icon.
Later, and I have no idea what caused this change, any time I created a new activity everything would be completely empty (see image below) with any type of new screen that I would create. Not only that, but Android Studio no longer would create the default content.xml, but only the activity.xml which everything would be edited in.
This would not be a problem normally, I just edited everything in the activity.xml for any new screen that I would make. This works fine for any test phone (avd). However, when I try it on a real phone none of the new screens work and causes the app to crash. I fear this may be because it doesn't follow the earlier default layout of having both content.xml and activity.xml. I tried to create the content.xml for any of the new screens, but I got a rendering error.
My question basically asks is there anything I can do apart from starting over?
How do I change back to the default for creating new activities?
Is there an easy way to copy code in case I need to start over?
(I'VE TRIED BOTH NEW BLANK AND NEW EMPTY, BOTH DON'T WORK YET WORKED EARLIER)
Image

Why is there a loading spinner in my action bar and how do I remove it?

Basically I'm pretty new to android development but so far I've been able to fix every issue/bug I've had except this one (I've seen way worse, but for some reason this little bug takes all my time..).
Just for contact, I'm doing an application that loads local and external xml file and displays the content, fetch xml files from a server and save them locally, etc.
The issue I'm running into is the following; on older android phones (on 4.4 there is no issue, on 4.0 there is) when the application loads, I have a loading spinner icon in my action bar while the only place I use one is in another layout that is not referenced in my main activity. I figured maybe it's because I didn't initiate my menu correctly or something, but everything seems fine (and works on newer versions). I have a searchview that is working fine, a settings menu that is also fine, but for some reason there is always a spinning icon next to those elements.
I can edit this and add my layout/code if needed.
Thanks!
maybe put setProgressBarIndeterminateVisibility(false) in Activitys onCreate (check docs)

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.

Categories

Resources