• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How is this interface implemented?

Hi all. I wrote a simple weather app which goes fetches data from Openweathermap's API in Json format. I used an Aynctask to fetch the data, using ideas from online (as we all do!)
All works ok, but I am trying to get a better understanding of the callback implementation (similar to the one at http://smartandroidians.blogspot.com/2015/03/how-to-use-callback-or-interface-pass.html)
In particular, I am trying to understand how is the interface is implemented without the keyword 'implements' anywhere?
The Async thread:

Java:
class MyTask extends AsyncTask {
public interface OnUpdateListener {
public void onUpdate(MyObject obj);
}
OnUpdateListener listener;
MyTask() {
}
public void setUpdateListener(OnUpdateListener listener) {
this.listener = listener;
}
MyObject doInBackground() {
return obj;
}
onPostExecute(MyObject obj) {
if (listener != null) {
listener.onUpdate(obj);
}
}
And in the main thread:
Java:
yActivity extends Activity {
void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyTask  task = new MyTask();
task. setUpdateListener(new MyTask. OnUpdateListener() {
public void onUpdate(MyObject obj) {
.....
}
});
task.execute();
}
}

Then in the code that I did:
Java:
public class fetchData extends AsyncTask<Void, String, String> {
    //------------added--------------
    public interface AsyncResponse {
        void processFinish(String output);
    }
    public AsyncResponse  delegate = null;//Call back interface

    public fetchData(AsyncResponse asyncResponse) {
        delegate = asyncResponse;//Assigning call back interface through constructor
    }
//---------------------------------------
    String data = "";
    String dataParsed = "";
    String singleParsed = "";
    String iconValue = "";



    protected String doInBackground(Void...voids) {

        try {

Thanks all
Russell

New Game: Princess Cute Kitty (Version 1.0.9)

EXTRA INFO
  • Rating: 4.6
  • Installs: 10+
  • Download Size: 76M
  • Version: 1.0.9
DESCRIPTION
Enjoy time with your pet cat ! Take care of your cats, feed it, and play with it. your cats will play with you .To better care for cats, you need to do the following......

Description
Build your own Kingdom, There are many things to explore, and there are countless stories to be told and to take risks. Open the game, gorgeous and warm castle opened the door to you, cute cats are lined up in a neat queue, waiting for your care and companionship 。you can dress up the princess,building a castle.

The main features:
● 7 fun mini-games
● Guess the cat in the treasure chest
● Clean the cat's room
● Make cakes for cats
● Dress up princess
● Shoot balloons with cats
● Get gold coins to create your own kingdom by playing various mini-games
● Cat swimming competition

sound and mic doesn't work

Hi everyone, i need a little help, so back in 2016 i got a samsung galaxy note 3 and it was already rooted when i got it bc i bought it from a friend, everything is was okay, until one day i started messing up with it, so i went online looking on how to boost my sound with headphones and so like i tried to follow a tutorial walking me thru on how to go to some folder within the phone system i don't know what it really was tbh because i clearly don't know anything about it i remember it being within the root folder an archives and like i remember it was this paragraph of numbers and letters and commands and it was extremely long and i had to scroll down all the way down and i had to like delete a certain word or like command and type something else so i did and like i kept following the tutorial and it said i had to restart my phone so i did and ever since then i stopped working, shortly after that i had to get a new phone but i recently went to my parents house getting some stuff and i found it sitting there getting dust and like its fully funcional and i find no answers online about it, also this was like 4 years ago and i don't really remember what i did, can someone help me figure this out? also im trying to update the software because its at 5.0.2 lollipop

Help I'm new and don't understand

I'm so much concerned about it using my data..I am more curious what app it is?? And why it says restricted? Could it be a spy app? Also when I go to the wifi it doesn't show up there??

Hi, Brooke.

I'm a user that tends to go after root-level privileges, but I can tell you this:

If you go to F-Droid, you can find apps that are VERY data friendly compared to what you would get at G-Play; there's an app there called SuperFreezZ. It is designed to "hibernate," or freeze apps so that data transmissions get slowed down & reduced a bit. Download the F-Droid kDi first (after you create an account), then look through the apps that they have (i.e., they have a great calendar app called Etar; it also uses less data & memory).

Another location to check out is XDA Developers. They have many good apps, and development to help you protect your privacy AND reduce data consumption from background-running apps... but F-Droid is where you should begin.

Good luck, Brooke -

LW

Android Studio wizard generates code with obsolete calls?

Hello,

I used the Android Studio to generate an app with a Login activity.

One thing called my attention.

One line of code is:

loginViewModel = ViewModelProviders.of(this, new LoginViewModelFactory())
.get(LoginViewModel.class);

Android Studio shows ViewModelProviders.of as Deprecated. Why is that? why last version of Android Studio generates deprecated code? isn't it supposed that Android Studio should generate code following best practices? best practices include code that is not obsolete.

Searching in Internet, I have found it can be replaced with:

loginViewModel = ViewModelProviders.of(this).get(LoginViewModel::class.java)

That is, can I remove LoginViewModelFactory class? Shouldn't I use wizards as a starting point of the application?

Any advice will be greatly appreciated.

Regards

App interface different in Android Studio and Emulator

Because you must implement constrains when you use Constrain Layout.
If you look at the designer, you can see an exclamation point with red background for each control: this means that the control has not constrains.
On the other hand, your app is not on google play store so to install it you must turn on setting about unknow app to be installed.
Hope this help.

Filter

Back
Top Bottom