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

Design Patterns

A lot of people who rushed into android world , Didn't take their time in Java , Actually i am one from these people , So, We didn't learn some important topics , One of them is design pattern.
I am reading a book of design patterns and i'll try to walk through it with you i'll just add the flavor of android , I hope i'll will
So let's start with Adapter pattern

What is Adapter Pattern?
It's like the name suggests , Converting one class to another one keeping only the name of its methods name but functionality of the other's.

Why would i need it?
Sometimes you use a class for a while,Then, You find out that you need to switch to another one ,But, It will take you much time and efforts to edit all the code.

How to implement it?
Create a new class "Adapter" which has the name of the class you want to switch to "By extending it" and has an object of type of the old class , Use the data you passed to the old class in the new class.

Example
I'll get enough to show the concept , And, i'll wait your opinion if you need a kind of real example.

We need ,For example, Switch
class A to class B
Java:
public class A {
    private String Name;
    private String ID;
    private int age;

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}

Java:
public class B {
    private String mail;
    private String nickname;
    private int yearOfBirth;

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public int getYearOfBirth() {
        return yearOfBirth;
    }

    public void setYearOfBirth(int yearOfBirth) {
        this.yearOfBirth = yearOfBirth;
    }
}
Java:
public class AtoBadapter extends B {
    private String mail;
    private String nickName;
    private int year;
    private A a;
    public AtoBadapter(A a){
        this.a = a;
        convert();
    }

    @Override
    public String getMail() {
        return mail;
    }

    @Override
    public void setMail(String mail) {
        this.mail = mail;
    }

    @Override
    public String getNickname() {
        return nickName;
    }

    @Override
    public void setNickname(String nickname) {
        this.nickName = nickname;
    }

    @Override
    public int getYearOfBirth() {
        return year;
    }

    @Override
    public void setYearOfBirth(int yearOfBirth) {
        this.year = yearOfBirth;
    }
    private void convert(){
        this.mail = a.getName().concat("@yahoo.com");
        this.year = 2020 - a.getAge();
        this.nickName = a.getID();
    }
}

Java:
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        A a = new A();
        a.setAge(20);
        a.setID("z0-4");
        a.setName("A");
        B b = new AtoBadapter(a);
        analyze(b);
    }
    public void analyze(B b){
        //Do what you need with B class

    }

}


weird crash

If this 'crashing' issue is only happening to the Running Services option, I don't have a clue as to how to fix that. Developer Options isn't an app, its an integral part of the Android OS.
But if this is about your the Android operating system that's not stable anymore (it's not just Running Services but your phone itself), if you're still covered by a warranty it might be time to take your phone into to have it looked over. Or if you prefer, try flashing a stock Samsung ROM yourself. Your profile shows your carrier is AT&T, go here:
https://www.sammobile.com/samsung/galaxy-s10-plus/firmware/SM-G975U1/ATT/
If that's not your carrier any longer, go here:
https://www.sammobile.com/samsung/galaxy-s10-plus/firmware/
Be sure to select the ROM that's an exact match to your model. ROMs are not interchangeable so be sure to pick the one that matches your model, your country, and your carrier. The download page of the ROM you select has instructions on what steps to take to do the flashing process.

Anyone have a Hyundai Koral tablet?

...Another problem is that some reviewers expect cheap tablets to perform like expensive ones.
Read through the link I posted from Wirecutter. Even if you don't want to buy their recommendations, scroll down through the article as they also include a lot of details about what metrics they use to make their choices based on typical consumer scenarios. This gives you a better idea to make more informed choices on what to buy and what to avoid.

How to get files from a Samsung with broken and blackout screen

You are really unlucky that it's an S6. Older Samsungs supported video output via MHL, which would let you mirror to a screen. And I think the current ones support HDMI via USB. But as far as I can tell the S6 supports no wired video output (and mirroring via chromecast is useless here as you can't enable it without seeing what you are doing).

You might think "what good does mirroring do if the touch doesn't work?", but you can control a phone using USB OTG and a keyboard or mouse, and although it involves a lot of tedious trial and error you can do quite a lot by swapping between a display and an input device (with one socket you can't use both at once, unless you can pair it to a bluetooth input device). But this doesn't help you because I can't think of a way of mirroring the S6's display other than wirelessly, and I'm sure you need to have already set that up to have a chance of it working now.

J5 won't boot up with sim card in

Hi my galaxy s7 edge recently died so I decided to put the sim into my old J5. Without a sim card in the phone boots up fine and connects to wifi etc. However when I put the micro sim in with a sim card adapter the phone wont boot up, If I start charging the phone with the sim card in then I get a black screen with the phone charging icon flashing and a slight vibration like a notification vibration. Any ideas on a fix? tried different charges and cables but same issue, the phone battery is also about 80% charged.

Random volume changes both all the way down and all the way up w/headphones

The only time this has happened to me is with a certain set of headphones. This particular set covers the ears, but is lightweight and sounds good, yet will allow sound from around me to get through. So I really wanted to use this set for my phone.
It may be that the heaphone plug is a micron out of size, an impedence mismatch (the speakers and the device internals are a poor match electrically), or something else I haven't thought of.

The headphones that do this work great in other things I plug them into, but when plugged into a phone the volume goes bananas just as you describe. I have seen Google Assistant turn on, the music app quit and start, or change songs, and other annoying things.

It seems that when I wiggle the jack is when it occurs most often, although it also happens just by bending the cord near the end sometimes. Sometimes I don't know what sets it off.

It only happens with one headphone set, and that set has a three section plug- two plastic bands dividing up the metal segments of the plug.

I have other sets of headphones that work just fine in the same phone.
Some have three section plugs, others have two section plugs.

The extra segment on the three segment plugs is for a microphone.

I don't know if this has anything to do with it, as I have another set with the same set-up that works fine.

My guess is that the end of the cord is worn, probably internally so that it is not visable damage, and this is causing either a temporary short circuit or a temporary break in the connection. This can cause all sorts of things on a device like a phone.

If it is happening with a cheap set of headphones, try a better quality set. ($10-$20 USD)
If it is happening with a high quality set of headphones, then try a cheap set. ($5-$10 USD)

If both are doing it, then possibly the jack on the device is misaligned internally.

Help X on top left of screen

First I would try tapping the 'X' to see what happens.

If nothing, then I would pull down the notifications by swiping from the top of the screen downwards.

All notifications should appear, and when you tap then slide one a bit to the right a settings pinwheel should pop up.

This will take you to the notification settings for the app.

If nonet of your notifications relate to this icon, then go into your developers options.

Check the running apps, and stop each one until the icon disappears.

Don't have Developers Options in your settings?

Open settings, scroll down to About Phone
Tap the Build Number 7 times.

Now when you open Settings, down near the bottom you should see Developers Options.

Help Battery virus

I've been getting a pop-up saying my battery has a virus , when online.
Is this a real thing , or is it a scary tatic to download the app that is in the battery has a virus pop-up.
HELP PLEASE ???

It is poop.
There are many of these crappy ads out there, some even claim to be right from Google.

WARNING! YOUR DEVICE IS 28.4% INVECTED BY 4 VIRUSES!
If you do not act within 4 minutes, your device will be locked after 24 hours.
Click 'OK' below to remove viruses now.
[ OK ] 3:59

I have seen this one hundreds of times.
If you click OK, it invariably takes you to some BS app in the PlayStore.

This is how your phone gets a disease, and how users get frustrated.
It is also how these devs get clicks and downloads.

Any app that these ads lead to is junk at best, and spyware at worst.

I use to make a point of leaving bad reviews and reporting the apps to Google- but it seems that they don't care or are part of the scam too.

Thom Browne edition anyone else?

For those that asked, the watch is 40mm stainless steel. Overall I think it's a great bargain compared with their clothing line.

Sad to say I will be returning the phone. As much I tried to like it didn't feel balanced and it was to narrow to my liking. I didn't want to bother with selling it on ebay but I will miss the bud plus they are amazing. Once i get my refund I will be upgrading my buds to their plus. The active watch 2 face is larger than the active watch but not paying 100 plus for the upgrade. Now if it was ceramic I may uograde

Looking forward to the fold 2 but in the mean time I'm back with the s10 plus the perfect phone for me for now.

[FREE][APP] Tappy - Promote Your Social Media Accounts

Hello everyone!
I've recently released an app that helps you to promote your social media account in a fun way for free. You basically have to gain points in order to appear in a daily rank, where other people can visit the profile that you want to promote. It can be Instagram, TikTok, Youtube and Twitter. You will also gain points by checking the other accounts!

It is still in a initial phase, so there is not so much traffic yet, but I hope you'd like to try it anyway to give me your feedback :)

Here is the link:
https://play.google.com/store/apps/details?id=com.emafra.taptobefamous

Root How to change build.prop from computer (not from phone using root explorer)

First of all, I'm sorry for my bad english.

My Samsung S5 Dou Android device is rooted and I was trying to edit the "build.prop" file in root directory and inside it, i edit the SDK Version which is from 19 into 23, then after I rebooted it, all the apps even the file manager i use to edit the file were stopped working so now I cannot edit or back the file into its original and i tried to format the device because I thought it would work to avoid the stopped working or the error were gone, but unfortunately its not working, it's still showing the popup :< My problem is, I cannot really use the phone because all the settings or apps are not working :< I tried to use drfone or other phone formatter but its still not working because its need to enable the USB Debugging and I cannot enable it because even the settings will stopped :< Anyone there know to fix my phone? :< This is my only phone givin from my grandfather :< Thank you guys and sorry for this complain :< Thank you!

Filter

Back
Top Bottom