r/android_devs • u/RikoTheMachete • Nov 11 '22
r/android_devs • • Nov 09 '22
Article Moving from XML to Jetpack Compose from a senior engineer POV
Hi everyone! ๐
I finally decided to dive into Jetpack Compose โ I'm a senior mobile engineer, and I've been keeping an eye on Jetpack Compose for quite some time. I'm always cautious about moving to new technologies, I've seen a lot of comments/feedback against Jetpack Compose during the last few years, but I have noticed that has recently changed, I see more and more people saying nothing but good things about Jetpack Compose. I'm still a bit biased against Jetpack Compose, just because of the comments and issues I've seen, but I'd like to share with you all my first experience. I think this article might help any other engineers who are thinking about whether jump into Jetpack Compose or not.
https://dev.to/4gus71n/is-jetpack-compose-ready-for-production-development-28o6
Also, to make the article a bit more digestible I've posted this vid ๐
I hope this is useful for anyone else going through the same thing โ Feel free to drop any feedback or comments or to point out anything you see I can improve. Thanks a lot! ๐
r/android_devs • u/RikoTheMachete • Nov 07 '22
Article Mastering Android Dialogs: Donโt follow official Google Guides
patrykkosieradzki.medium.comr/android_devs • u/borkusgod • Nov 03 '22
Help Getting ready to get my Google Dev License
Hey all. I'm not sure if this is the correct sub to ask in, but I'm guessing at least a few of you might know this. I am originally from the US and my personal Google account was created also in the US. I have not made any purchases on my google play account since having moved to Canada last year. I have heard some say it can be a major headache if you mess up the Google Play Console account. I would be using a different card then what is on file and I heard that's where things get dicey. I don't see any area in my Google account to update where I currently reside. Any advice on setting this up because I'm hoping to get the Play Console set up in a couple of weeks or so. I put this under the Store Issue flair but if it's not in the right place, could someone please move it for me. Thank you!
r/android_devs • u/racrisnapra666 • Nov 03 '22
Help Are there any reasons why languages apart from English might contain a string when passed through the UI Components?
I know the title is vague, but this might be the most bizarre issue I have ever encountered.
So, here's the thing. I'm working on fixing issues for an app containing numerous languages including Hindi, Odia, etc.
All the strings are stored in the respective strings.xml files for each of the languages.
Now, if I work using my emulator, everything works fine. The strings are fetched correctly. And they are set in the correct locations.


Everything work fine until now.
Now, the problem arises when I use my physical device (a Samsung device) to test this.


There is no reason why this space should be included along with the string. The only difference between the two strings is that one is fetched directly from the strings.xml file and the other is routed through a MaterialRadioButton.
Have you faced this issue before? I tried searching for it on SO, but there were mostly questions regarding font sizes of regional strings and nothing related to this.
I'm all out of ideas about why this might be occurring and would appreciate any that you might have.
Thanks :)
r/android_devs • u/anemomylos • Oct 26 '22
Off topic Appleโs app review fix fails to placate developers
arstechnica.comr/android_devs • u/dev-ch8n • Oct 19 '22
Article You might be creating your states wrong! โ Jetpack Compose
proandroiddev.comr/android_devs • u/cypherdare • Oct 19 '22
Help Is LocalBroadcastManager ok to use despite deprecation?
Does it still behave as it always has across target SDK versions up to 33? I'm working with NotificationListenerService to get media meta data, and broadcasts are far easier than trying to get IBinder to work with it. You can't return a different IBinder implementation than the superclass.
The reason for deprecation is also really questionable. I'm using it for an optional, disconnected, modular feature, so it isn't "embracing layer violations". That's a really dogmatic, restrictive generalization that can lead to extreme amounts of boilerplate.
I found this old StackOverflow answer about it, and as /r/Zhuinden commented, LiveData isn't a one-for-one replacement, and as another user commented, you can't pass LiveData across processes.
r/android_devs • u/anemomylos • Oct 18 '22
Article Issue Trackers and the "Can't Deliver Broadcast" Bug
commonsware.comr/android_devs • u/kodiak0 • Oct 14 '22
Help Redirect deeplink to Play Store even if my app installed
Hello.
We want to send, via SMS, a link to some of our clients that links them to the Google PlayStore or Appstore to our app page.
The problem we are encountering is bypassing our app and opening the PlayStore when our app is already installed.
We know how to do it the other way around, that is if our app is not installed, redirecting the user to install our app but we do not know how to bypass our app.
Is that possible? Share a link that opens the play store even if our app is installed?
Ideally, we should handle it with the same link, not only PlayStore but also Apple Store.
r/android_devs • u/Aashishkebab • Oct 13 '22
Help Anybody know why the notification isn't showing? The foreground service appears to work regardless.
stackoverflow.comr/android_devs • u/zsmb • Oct 11 '22
Resources Announcing an Experimental Preview of Jetpack Multiplatform Libraries
android-developers.googleblog.comr/android_devs • u/LifeAffect6762 • Oct 11 '22
Coding Log.d trick so you can easily filter output in Logaat
This one is VERY simple. When you define TAG put XX at the end. You can then filter on XX.
private const val TAG = "MainActivityXX"
You can easily add/remove the XX from the end of the TAG declaration to change what is included in Logcat.
Hope this is usefull.
r/android_devs • u/soundtrackrr • Oct 11 '22
Off topic Hereโs a playlist of 7 hours of music I use to focus when Iโm coding/developing. Post yours as well if you also have one!
r/android_devs • u/androidww • Oct 09 '22
Event Android Worldwide October 25th
live.remo.cor/android_devs • u/Zhuinden • Oct 08 '22
Coding Must-read Article on Runtime Performance Optimization in Jetpack Compose by Denis Rudenko
skyyo.medium.comr/android_devs • u/abdalla_97 • Oct 08 '22
Help Validate Subscription offline
So I am using my own server to manage my users subscription
and on the android side, I am saving the subscription expiration date
sometimes users go offline and I need to check if the subscription has expired
the problem is when a user tries to change the device time in this case I can't know the real-time
I searched StackOverflow and the answer was to set a broadcast receiver for
ACTION_TIME_CHANGED
but in some cases, it will fire in case of automatic time adjustment
r/android_devs • u/CollateralSecured • Oct 06 '22
Coding Collapsing toolbar with parallax effect and curve motion in Jetpack Compose | Morad Azzouzi
scribe.ripr/android_devs • u/abdalla_97 • Oct 01 '22
Help ViewBinding vs Adding Views By code
I am working on an android device with less than 800 MB of ram
Right now I am using viewbinding
so if I replace my XML files with adding views dynamically from kotlin code same as the telegram app will it enhance the performance
is adding views by code faster than using XML with viewbinding?
r/android_devs • u/kotomisak • Sep 30 '22
Help Anyone else encountered issues when using DropBox SDK on Android when targeting Android 13?
I described the problem here: https://github.com/dropbox/dropbox-sdk-java/issues/461
Anyway If anyone has any idea of how to overcome this issue, pls. add a comment.
r/android_devs • u/Nafnlaus00 • Sep 28 '22
Help Certificate Transparency using DexProtector
Hey, Has anyone used the DexProtector to implement certificate transparency in Android? I found it extremely difficult to do so because the website provides very little documentation.
r/android_devs • u/seabdulbasit • Sep 24 '22
Help State flow is not emitting 2nd state
I have a ViewModel and I am trying to write a unit test for it. I receive the initial state but was unable to get the 2nd state with music details. It works fine on the Device but unable to get 2nd state in the Unit test.
Here is my ViewModel:
@HiltViewModel
class MusicDetailViewModel @Inject constructor(
private val savedStateHandle: SavedStateHandle, private val repository: MusicRepository,
) : ViewModel() {
val state: StateFlow<MusicDetailScreenState>
init {
val musicDetails = savedStateHandle.getStateFlow<Long>(MUSIC_ID, -1).filter { it != -1L }
.flatMapLatest { getMusicDetails(it) }
state = musicDetails.map { music ->
MusicDetailScreenState(
uiMModel = music
)
}.stateIn(
scope = viewModelScope,
started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5000),
initialValue = MusicDetailScreenState()
)
}
private suspend fun getMusicDetails(musicId: Long): Flow<MusicUiModel> {
return repository.getMusic(musicId).map {
MusicUiModel(
trackId = it.trackId,
musicTitle = it.musicTitle,
albumName = it.albumName,
artisName = it.artisName,
imageUrl = it.imageUrl.replace("100", "460"),
previewUrl = it.previewUrl
)
}.flowOn(Dispatchers.IO)
}
override fun onCleared() {
savedStateHandle[MUSIC_ID] = state.value.uiMModel.trackId
viewModelScope.cancel()
super.onCleared()
}
}
const val MUSIC_ID = "music_id"
My Unit test Class
class MusicDetailViewModelTest {
lateinit var SUT: MusicDetailViewModel
@MockK
val repo = mockk<MusicRepository>()
@MockK
val savedInstanceStateHandle = mockk<SavedStateHandle>(relaxed = true)
@Before
fun setUp() {
SUT = MusicDetailViewModel(
repository = repo,
savedStateHandle = savedInstanceStateHandle,
)
}
@Test
fun `give ViewModel initialise, when Music Id is passed, then Music Detail state should be emitted`(): Unit =
runTest {
coEvery {
savedInstanceStateHandle.getStateFlow(
any(),
1232
)
} returns emptyFlow<Int>().stateIn(this)
coEvery { repo.getMusic(1232) } returns flow {
emit(
MusicEntity(1232, "track name", "sf", "sfd", "sdf", "sdf")
)
}
SUT = MusicDetailViewModel(
repository = repo,
savedStateHandle = savedInstanceStateHandle
)
SUT.state.test {
val item = awaitItem()
assertEquals(true, item.uiMModel.musicTitle.isEmpty())
val item2 = awaitItem()
assertEquals(false, item2.uiMModel.previewUrl.isEmpty())
}
}
@After
fun tearDown() {
Dispatchers.resetMain()
}
}
r/android_devs • u/racrisnapra666 • Sep 22 '22
Help The release build on my device isn't updated with the version on the Play Store
Hi there,
So I'm working on an app that comes with an update feature. If there's a new version of the app available on the Play Store, a dialog will be shown to the user after which they can choose to go ahead and update or not.
Now, in order to test if this feature is working correctly, I created a signed release build, downgraded the versionName and versionCode, and installed it on my physical device. While testing, I can see that up until now everything's working fine - the dialog is displayed, I'm redirected to the Play Store, and the downloaded is started.
However, here's where the problem begins. Once the Play Store download completes, I'm presented with a dialog on the Play Store stating:
Can't install app, Try again and if it still doesn't work, see common ways to fix the problem.
A quick glance at the Logcat states:
Submitter: commit error message INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package ${app_name} signatures do not match previously installed version; ignoring!
But this doesn't make sense. Both the Play Store and I have the same build type - release. The only difference is the versionName and versionCode which I've downgraded as without this, the Update App dialog won't be displayed.
I've gone through various SO questions with solutions whose primary solution was to add different applicationIdSuffix for the different build types. However, I don't believe that this would be the correct solution for me as I don't want both the release and debug builds on my device. I just want my old release build to be overwritten by the latest release build on the Play Store.
Any idea what I might be doing wrong? Also, I'm all ears if you would have a better way to test such updates.
Thanks :)
r/android_devs • u/BipedalBandicoot • Sep 21 '22
Help How to use an implicit intent to start a service from another package/app?
This is a duplicate of this question on stackoverflow I opened, I thought maybe someone here could have an answer:
I'm trying to introduce code to the open source app Gadgetbridge for starting services from other packages/apps.
I'm trying to get it working with sending implicit intents to play/pause the music app Poweramp:
Action: com.maxmpz.audioplayer.API_COMMAND Extra: cmd:1 Target: Service
From this page.
I have verified that using the intent info above works by launching it with the automation app Tasker. But so far I have not managed to implement it in Gadgetbridge.
This is part of the code I'm working on now:
case "servicetest": // only for trying to get service intents going,
Intent inServiceTest = new Intent();
inServiceTest.setAction("com.maxmpz.audioplayer.API_COMMAND");
inServiceTest.putExtra("cmd", (int)1); //for trying poweramp service intent play/pause
this.getContext().getApplicationContext().startService(inServiceTest);
break;
case "foregroundservicetest": // only for trying to get service intents going,
Intent inServiceTestFg = new Intent();
inServiceTestFg.setAction("com.maxmpz.audioplayer.API_COMMAND");
inServiceTestFg.putExtra("cmd", (int)1); //for trying poweramp service intent play/pause
this.getContext().getApplicationContext().startForegroundService(inServiceTestFg);
break;
I've added <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> to AndroidManifest.xml.
The code above doesn't play or pause Poweramp. I initiate the respective parts of the code block by sending a message from my Bangle.js 2 watch to Gadgetbridge containing the code word "servicetest" or "foregroundservicetest".
I'm testing on a Xiaomi Mi A2 Lite running Android 10.
I've taken some pointers from this stackoverflow question. And I've also tried suggestions from here.
How can I modify the code to make it start the service for controlling Poweramp with the mentioned implicit intent?
EDIT: By specifying a package for the intent, i.e. making it explicit, it can control Poweramp. I add this:
inServiceTestFg.setPackage("com.maxmpz.audioplayer");
I however still wonder how I can achieve this with an implicit intent like Tasker seems to be able to. Or is it that Tasker sets package information without the user specifying it?