Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
2 answers
142 views

How to fix duplicate code fragment in android

I have this function to update my ImageView in my android project private fun weatherImageSetup(currentWeather: CurrentWeather) { fun setImage(imageId: Int) { viewBinding....
HaBuiDuc's user avatar
  • 115
0 votes
1 answer
58 views

Implementing the same feature on two app versions

I have two versions of an app (paid and free). When I add a new feature in both versions I have to write the same code on both of them. Is there a way to write the code on one of them and then add ...
Mike087's user avatar
  • 491
0 votes
1 answer
100 views

Should similar screens be different Fragments?

Ok so I'm creating an app. I have a "Creation" page, and a "Detail" page for the same item. The UI is the same, probably the logic will be the same as well, only difference i can ...
alessandro gaboardi's user avatar
4 votes
1 answer
2k views

Finding duplicated code (Kotlin) in Android Studio

Is there a way to find duplicated (Copy/pasted code, repeated code) Kotlin code in Android Studio? I have Android Studio 4.0 but can't find this "Duplicated code fragment" option. Are there any ...
AndroidDev's user avatar
  • 5,555
1 vote
1 answer
289 views

How to avoid duplicate code in the activity and fragment?

When an activity is launched, the condition is checked in it, if the condition is true, the openNewActivity method is called and the current activity ends. But if the condition is false, then a ...
aqellaa's user avatar
  • 51
-3 votes
1 answer
30 views

How to avoid duplicating the same chunk of code?

I am a beginner developer of an Android app and have a structure related question. In my app I have a few screens with buttons that allow us to switch between these screens. Right now I am setting ...
anne's user avatar
  • 39
-1 votes
2 answers
111 views

showing some view in all activities without duplication of code in Android

I have a condition when a specific event will occur in background, I have to show a Floating Action Button in bottom of activity to notify the user if App in fore ground. No matter in what activity ...
Mahendra Chhimwal's user avatar
1 vote
1 answer
464 views

Android: one or two activities for same layout/similar functions

I'm fairly new to Android development and have a question regarding best practices for designing Activities. I have two activities that use the same layout, but their functions differ a bit. One ...
Eve's user avatar
  • 1,238
1 vote
1 answer
2k views

Alternative Layouts

I am developing an android application that I want to support Material Design for devices running 5.0+ and devices from 4.1 to 4.4. I am using the appcompat library to get some support for older ...
Tiago Veloso's user avatar
  • 8,563
-2 votes
1 answer
170 views

Duplicate error-noob programmer

Here's my code, I have no idea what is wrong with it I am completely new at this and I would appreciate it a lot if I can receive some feedback thanks:)When I try to launch my app in the emulator it ...
Kamran's user avatar
  • 1
2 votes
1 answer
546 views

Better way to create Android content providers

I have a content provider in my app and I really don't like it :-). The provider is created after reading number of articles like the official one and this unofficial one. What I really don't like is ...
Bobrovsky's user avatar
  • 14.2k
14 votes
6 answers
14k views

Best way to avoid duplicate code if two classes extending different class

I am working on an Android project and i am facing this situation. I have 2 class : class A extends B { openDoor(){ //impl } closeDoor(){ //impl } } class X extends Y{ openDoor(){ //impl } ...
user3114009's user avatar
2 votes
1 answer
320 views

Android: implementing very similar layouts/activities

I'm a beginner to Android development and I'm implementing an address book app. This app will need an 'add contact' screen and an 'edit contact' screen. These screens are going be pretty similar - '...
false_azure's user avatar
  • 1,493
0 votes
2 answers
179 views

feinstein's SlidingMenu library, Define BehindContentView in every activity?

I am using feinstein's SlidingMenu library, I want to use the SlidingMenu in every activity i have. Should I have to write the SlidingMenu code in every activty?!, or can I write the slidingMenu in a ...
Coderji's user avatar
  • 7,745
1 vote
1 answer
288 views

Conditionally adding extra else if statements

The following is called from every level of my app (a game) Pseudo code example public void checkCollisions(){ if (someCondition) do something else if (someCondition2) do ...
Zippy's user avatar
  • 3,877
3 votes
2 answers
1k views

How can I avoid code duplication with Fragment callbacks to a details activity?

I'm using a master/detail pattern with one activity managing the 2-pane view and the selector list and the other activity managing the detail fragments. I'm using an interface to handle fragment ...
Mike T's user avatar
  • 4,787
1 vote
5 answers
222 views

How do I reduce this code duplication

I'm stuck on how I can reduce this code duplication, I'm using the TextToSpeech engine and using locales so the user can select their language. language is a Spinner. language....
orange's user avatar
  • 5,395
0 votes
1 answer
373 views

Making Android/Java code more efficient - removing duplicate

I have a standard AsyncTask like this: // starting AsyncTask in onCreate new TaskName().execute(); class TaskName extends AsyncTask<String, String, Void> { private ProgressDialog ...
TheLettuceMaster's user avatar
1 vote
2 answers
249 views

R unresolved variable when duplicating activities

I am attempting to duplicate my project with a different title and package name. However, when I copy and paste the activities, it returns that R is an unresolved variable that I can either import ...
Cole's user avatar
  • 13
1 vote
2 answers
325 views

How to avoid having duplicate code for fetching location and data in every activity?

I have 2 activites (one with listview and 1 with mapview). Both activities have refresh button that fetches location and then downloads some data from the internet. I have duplicate code for location ...
DixieFlatline's user avatar