• Breaking News

    Tuesday, January 5, 2021

    Android Dev - Weekly Questions Thread - January 05, 2021

    Android Dev - Weekly Questions Thread - January 05, 2021


    Weekly Questions Thread - January 05, 2021

    Posted: 05 Jan 2021 06:00 AM PST

    This thread is for simple questions that don't warrant their own thread (although we suggest checking the sidebar, the wiki, our Discord, or Stack Overflow before posting). Examples of questions:

    • How do I pass data between my Activities?
    • Does anyone have a link to the source for the AOSP messaging app?
    • Is it possible to programmatically change the color of the status bar without targeting API 21?

    Large code snippets don't read well on reddit and take up a lot of space, so please don't paste them in your comments. Consider linking Gists instead.

    Have a question about the subreddit or otherwise for /r/androiddev mods? We welcome your mod mail!

    Also, please don't link to Play Store pages or ask for feedback on this thread. Save those for the App Feedback threads we host on Saturdays.

    Looking for all the Questions threads? Want an easy way to locate this week's thread? Click this link!

    submitted by /u/AutoModerator
    [link] [comments]

    Best approach for a free and paid version?

    Posted: 04 Jan 2021 09:37 PM PST

    What is the best approach from a developer standpoint? Two app projects? Should it be managed via build variant, then how is that uploaded, etc. And pointers would be awesome as this is my first attempt at a paid app along side a free app.

    submitted by /u/ohlaph
    [link] [comments]

    My Google Play account is suspended for no reason!!!

    Posted: 05 Jan 2021 01:01 AM PST

    Hello guys,

    Google suspended my Google Play account for ridiculous reasons, and the support team replied "we can't provide more details" when I sent an appeal!! What a shame.

    I've had a reward app. They suspended my app a few weeks after it's been published. They asked me to update my app and publish a new one, so I did. For the second time, they suspended my app because there was the word "install" in my app's description!! My app totally complied with their policies but the description didn't! I asked them to let me edit the text but they gave me the same answer "we can't provide more details please update your app and publish a new one!"

    It seems that a robot answers appeal requests.

    For the third time, As soon as our app was published they suspended my Google Play account! the reason? they said because two of your apps were suspended before!! Due to Google policies, I know that I have a third chance, but the support team (robot) did give me the same answer as before.

    I've read this The future of Android Development and noticed it happens to many developers. Please don't give up, don't let Google violate our rights. We need to stop them.

    submitted by /u/Specific-Amount-6395
    [link] [comments]

    Why is Databinding Compilation So Unreliable?

    Posted: 05 Jan 2021 06:45 AM PST

    Debugging with databinding works about 75% of the time. It will often fail on something untouched, then work immediately after with no changes. I would think it was an issue with my setup, but even the Google Udacity video has a little blurb about _If this doesn't work, clean and rebuild your project_.

    submitted by /u/intertubeluber
    [link] [comments]

    Error: FragmentManager is already executing transactions when rotating screen or interchanging Dark/Normal mode - Android Studio - ViewPager2 + Navigation Components in Kotlin

    Posted: 05 Jan 2021 06:08 AM PST

    Hello folks, it's me...again. I find learning android development very hard. Even the developer site is not good to learn for me.

    Ok, I'm trying to have an viewPager2 view with tablayout. I'm using the Navigation Components so the activity_main.xml points to my nav_graph and there I have my homeFragment. Now inside my fragment_home.xml I'm using <fragment> to include the fragment_container.xml where i want my viewpager2 with tabs. All the logic for the ViewPager2 is in my ContainerFragment.kt. Now it works fine for me, that means I can display the viewpager and the tabs and all is fine until I rotate the screen or switch to darkmode/normalmode on my device. Then the app will crash and i get:

    java.lang.IllegalStateException: FragmentManager is already executing transactions

    So, I'm not able to find the problem. I think that I have do something wrong with the setupFragmentManager. As far as i know i need it for my ViewPagerStateAdapter.tk.

    So what I'm doing worng? What I'm missing or misunderstanding? I know that if I would write the Viewpager into activity_main.xml and MainAktiviti.tk the rotation and transition to darkmode will work properly.

    My ContainerFragment.Tk is

    class ContainerFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { // Inflate the layout for this fragment var view = inflater.inflate(R.layout.fragment_container, container, false) //Get supportFragmentManager (maybe here my error is here????) var supFragMan = (activity as AppCompatActivity).supportFragmentManager //Initializing viewpager2 var viewPager: ViewPager2 = view.findViewById(R.id.viewPagerHome) //Initializing the Adapter var adapter = ViewPagerStateAdapter(supFragMan, lifecycle) viewPager.adapter = adapter //Integration of tablayout var tablayoutHome: TabLayout = view.findViewById(R.id.tablayoutHome) //Names of tabs var names: ArrayList<String> = arrayListOf( "FragmentA", "FragmentB", "FragmentC", "FragmentD" ) TabLayoutMediator(tablayoutHome, viewPager) { tab, position -> tab.text = names[position] }.attach() return view } } 

    Sorry if I'm disturbing you again and again, but I wanna learn to program.

    submitted by /u/KrabZka
    [link] [comments]

    Account suspended for Self-clicking

    Posted: 04 Jan 2021 01:26 PM PST

    I received email that my account is suspended for 30 days because of self-clicking. What is more ironic is that I don't even own Android phone. I always used test ads on my computer for testing purposes. I published my first app 20 days ago and I am so down right now. What can I do about this?

    submitted by /u/Bakero020
    [link] [comments]

    Is Firebase supposed to take up lots of RAM?

    Posted: 04 Jan 2021 03:30 PM PST

    My app was always using 200 to 300 MB of RAM on any device. I found that after completely deleting firebase it went down to 2 - 30 MB.

    Am I using Firebase incorrectly? I don't have any actual Firebase code in my app. All I did was enable Firebase crashlytics using the android studio assistant setup. And it works perfectly fine except for the massive RAM usage.

    submitted by /u/HiDiNoWro
    [link] [comments]

    App Update rejected due to Ad policy violation

    Posted: 05 Jan 2021 03:23 AM PST

    Hello frens.

    I was trying to update my app and got this message:

    We found an issue with the ad content in your app: Your app contains ad content that is not appropriate for children. Specifically, your app contains ad content that displays: Dating or Relationships: Ads for dating or adult relationship sites.

    If you monetize your app, please ensure you've excluded ads from sensitive categories. For more details, you can refer to the "Ads" section (#3) of the Families Policy Requirements, and you can view examples of inappropriate ad content on the Ads and Monetization policy page.

    The ad content in your app is not consistent with the app's content rating. To resolve this issue, please remove content not consistent with your app's rating and/or retake the content rating questionnaire. If you monetize your app, please ensure you've excluded ads from sensitive categories. For more details, you can refer to the "Ads" section (#3) of the Families Policy Requirements.

    Also got this threatening message:

    the previous version of your app is still available on Google Play. However, the previous version of your app may be subject to removal if you do not resolve the issue outlined below.

    The target age group for my app is: "Aged 5 and under, 6-8, 9-12, 13-15, 16-17, 18 and over". And it is not enrolled in the Designed for Families programme.

    So I went into AdMob (which I'm using to display ads in my app) and entered the Blocking Controls section and then went to "Ad content rating" which was set to "Mature Level Audiences". Setting it to "General Audiences" produces a big hit to advertisement revenue. Is there another way to fix this problem?

    submitted by /u/HiDiNoWro
    [link] [comments]

    WifiManger API Level 29+ Deprecated Mechanism Issues

    Posted: 05 Jan 2021 02:46 AM PST

    As for November 2020 Google Play store accepts only API level 29+ One of my apps relays heavily on wifi hotspot connection logic and in API level 29 a lot of it been deprecated and changed.

    One of my main issues is disconnecting and forgetting a network that was previously connected via the app..

    Here is the full SO issue: https://stackoverflow.com/questions/65576816/how-to-disconnect-and-forget-wi-fi-network-programmatically-in-and-above-android

    Any thoughts would be appreciated

    Eli

    submitted by /u/KittenOfMine
    [link] [comments]

    Retain fragment data on screen rotation

    Posted: 05 Jan 2021 06:07 AM PST

    I have 3 fragments where 1 fragment makes changes to the other 2.

    The problem is: When I rotate the screen background color and places of fragments 2 and 3 are restored. I want to keep them without modifying AndroidManifest.xml
    .

    Question on StackOverflow

    submitted by /u/shotx333
    [link] [comments]

    Complete Android Development Tutorial w/ Flutter

    Posted: 04 Jan 2021 10:17 PM PST

    Here is a link for those who want to learn Flutter for free - youtube.com/androiddev

    Hope this helps all new Devs !

    submitted by /u/FlutterTutor
    [link] [comments]

    Date conversion confusion

    Posted: 05 Jan 2021 05:47 AM PST

    I'm developing my first app and am a bit confused about the various date and time libraries and their usage.

    Basically I'm storing some values in SharedPreferences by string representation of relevant dates. I then need to use this data to draw a graph, so the values form the y-axis and then I somehow need to make the keys form the x-axis.

    I thought the obvious solution would be to get the dates in millisecond form from epoch to simply subtract the lowest key value from each so the keys would be in 0...n range, but I got confused in trying to convert a String to Long milliseconds... There's like a dozen different libraries regarding dates...

    Any hints would be appreciated!

    submitted by /u/TonyTheElf
    [link] [comments]

    UsageEvents.Event negetive usage value

    Posted: 05 Jan 2021 02:19 AM PST

    I'm trying to get application usage time of all applications installed in my phone :

    val manager: UsageStatsManager = context?.getSystemService(Context.USAGE_STATS_SERVICE) as UsageStatsManager val timeNow = System.currentTimeMillis() val cal: Calendar = Calendar.getInstance() cal.set(Calendar.HOUR_OF_DAY, 0) cal.set(Calendar.MINUTE, 0) cal.set(Calendar.SECOND, 0) cal.set(Calendar.MILLISECOND, 0) val range: LongArray = longArrayOf(cal.getTimeInMillis(), timeNow) val events = manager.queryEvents(range[0],range[1]) val event: UsageEvents.Event = UsageEvents.Event() while (events.hasNextEvent()){ events.getNextEvent(event) if(event.eventType==UsageEvents.Event.ACTIVITY_RESUMED){ Log.d("d--mua",event.packageName+" "+Date(event.timeStamp).toGMTString()+" ") val diff = System.currentTimeMillis().toInt() - event.getTimeStamp() Log.d("d--mua",diff.toString()) } } 

    But these are giving me time in negative :

    2021-01-05 15:04:28.249 23202-23202/com.mua.overwatch D/d--mua: com.android.systemui 4 Jan 2021 22:00:49 GMT 2021-01-05 15:04:28.249 23202-23202/com.mua.overwatch D/d--mua: -1610572917513 2021-01-05 15:04:28.249 23202-23202/com.mua.overwatch D/d--mua: com.miui.home 4 Jan 2021 22:00:50 GMT 2021-01-05 15:04:28.249 23202-23202/com.mua.overwatch D/d--mua: -1610572918599 2021-01-05 15:04:28.249 23202-23202/com.mua.overwatch D/d--mua: com.miui.home 5 Jan 2021 04:45:49 GMT 2021-01-05 15:04:28.249 23202-23202/com.mua.overwatch D/d--mua: -1610597217384 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.miui.securitycenter 5 Jan 2021 04:46:07 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597235206 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.facebook.katana 5 Jan 2021 04:46:09 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597236927 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.facebook.katana 5 Jan 2021 04:46:15 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597243732 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.facebook.katana 5 Jan 2021 04:46:43 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597271573 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.facebook.katana 5 Jan 2021 04:55:03 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597771294 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.facebook.katana 5 Jan 2021 04:56:15 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597843659 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.facebook.katana 5 Jan 2021 04:56:20 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597848423 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.facebook.katana 5 Jan 2021 04:56:34 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597861968 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.android.systemui 5 Jan 2021 04:58:02 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597950235 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.miui.home 5 Jan 2021 04:58:03 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610597951289 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: com.miui.home 5 Jan 2021 05:32:16 GMT 2021-01-05 15:04:28.250 23202-23202/com.mua.overwatch D/d--mua: -1610600004358 

    And how come it gives me data of 4 Jan along with 5 Jan when it is 5 Jan. And I've specifically set the query only for today here : longArrayOf(cal.getTimeInMillis(), timeNow)

    Can anyone help me with this one ?

    submitted by /u/maifee
    [link] [comments]

    Launching 3rd party apps in a Virtual Display?

    Posted: 05 Jan 2021 02:15 AM PST

    So sorry for this post, but I've been at it for 3 weeks and I'm about to give up.

    Just wanted to confirm if it is possible/impossible to launch an outside app (like youtube, reddit, twitter, etc...) from my own app in a Virtual Display without having my app as a system application, which involves rooting.

    Just wanted to know so I can either keep digging or move on to something else.

    Where am I at: getting the virtual display from a mediaprojection and bundle the display id with startactivity. Getting permission denial.

    submitted by /u/MrFarePlay
    [link] [comments]

    Developer Account

    Posted: 04 Jan 2021 05:47 PM PST

    Hi all i have my personal developer account but currently working as a freelance with a company and we want to publish the app so i just want to confirm because i know google has some strict weird rules about these stuff , is it ok for me to manage more than one developer account it wont effect my personal or the company account in the future?

    submitted by /u/beses
    [link] [comments]

    Good way to learn how to do UI?

    Posted: 04 Jan 2021 05:26 PM PST

    I am a programmer, and unfortunately UI design makes absolutely no sense to me. I'm bad at both knowing what to do and how to implement it. Anyone know a good tutorial or resource to learn either of those things?

    Thanks

    note: if this is not appropriate for the sub I'll remove

    submitted by /u/caprinaeAegagrus
    [link] [comments]

    Questions on Building Plain AOSP on MacOS/Docker

    Posted: 04 Jan 2021 10:58 PM PST

    Hi. I'm trying to build aosp code on native MacOS or in a Docker environment.

    However, I've encountered some problems and errors that prevented me from building the source code. The documentation i followed to build AOSP is ( https://source.android.com/setup/build/building ). Also I looked at some docker images if there are environments to build AOSP source code in the environment Google recommends. Unfortunately, most of the docker images seem to be outdated and not well maintained.

    I'm wondering if there is some thorough up to date documentation or guidance on building AOSP on MAC.

    submitted by /u/coearth
    [link] [comments]

    Emulate gyroscope from Console?

    Posted: 04 Jan 2021 10:18 PM PST

    Wondering if someone knows a simple way to emulate "shaking a phone" or moving of the gyroscope sensor, but from a command line environment. I have android X86 installed on virtual box with root permissions. My pixel 2 died and I have an app that requires this type of motion to function. Please advise. Thanks.

    submitted by /u/kfecho
    [link] [comments]

    Guide for In-App Purchase Setup on Google Play Console for Android apps

    Posted: 04 Jan 2021 05:39 PM PST

    �� Publish 2 same apps - free & paid version (No ads + extra features). Does it count as a Google Play policy violation?

    Posted: 04 Jan 2021 09:21 PM PST

    Repetitive Content

    We don't allow apps that merely provide the same experience as other apps already on Google Play. Apps should provide value to users through the creation of unique content or services.

    Examples of common violations

    Copying content from other apps without adding any original content or value.

    Creating multiple apps with highly similar functionality, content, and user experience. If these apps are each small in content volume, developers should consider creating a single app that aggregates all the content.

    submitted by /u/dust-in-the-universe
    [link] [comments]

    Anyone know a competitor to ARkit in terms of its shared reference across devices and spatial mapping?

    Posted: 04 Jan 2021 02:39 PM PST

    It seems like arcore doesn't have this capability yet, where you can determine shared spatial maps across multiple devices, No?

    For example, being able to see the same spatial map for various people in the room, so that one could interact with the same object and have it sync across devices. ARkit seems to have this capability, does google have any plans to add this?

    submitted by /u/scrublordprogrammer
    [link] [comments]

    Need help trying to get past Android Auto Review system

    Posted: 04 Jan 2021 01:52 PM PST

    I have had my app available for Android Auto for quite some time. In early November, I pushed an update, and the update was rejected for repeatedly crashing on Android Auto.

    I asked some clarifying questions. Eventually they told me when it got to the end of the playlist, the app crashed. I had been stopping the service when music was done playing, which doesn't result in a crash, but if the service stops, Android Auto says the app stopped working. I changed the behavior so that it would just pause and start the song over if they skip forward again.

    I finally got this to pass at the beginning of December. About a week later I pushed another update with a feature change somewhere else, and I again got the rejection about it repeatedly crashing. When I asked why, they said voice commands caused the app to crash. I tried all of the ones listed such as pause, play, skip, seek, and all worked. Any other commands such as playing a specific song re-direct to YouTube Music.

    I asked for a specific voice command and they said they were not allowed to share any more information with me and suggested I remove Android Auto from my app. I have tried a few more releases since then, not really changing anything to see if a different review would pass or talking to someone else, but they always say the same thing now.

    Does anyone have any suggestions about what I can do to figure out what I need to fix or someone else I can talk to? I tried contacting developer support and they told me to submit a request to the review team which is what I already did.

    submitted by /u/joelphilippage
    [link] [comments]

    Need Help in Uploading Multiple Images in Android Java

    Posted: 04 Jan 2021 07:36 PM PST

    Need Help in Uploading Multiple Images in Android Java

    So I am developing this app and asking users to submit 3 different images. Already created one previously (worked fine with 1 image only) and used BSImagePicker but it just won't work with this kind of setup. Can anyone suggest a good library or any other way? Thank you :)

    https://preview.redd.it/9wyhhde4of961.png?width=741&format=png&auto=webp&s=d0a1f52130fecc017cbaf8122618af6c6de75502

    submitted by /u/bevvcastillo
    [link] [comments]

    Confused on how to pass data to my recyclerView

    Posted: 04 Jan 2021 06:45 PM PST

    I'm a newbie here and to the development world but I'm stuck working on an app for school and was hoping that someone from the community could point me in the right direction.

    I have a fairly simple mobile app written in Java that uses the RoomDB and performs multiple DAO queries from each entity. The issues that I'm having is I'm not sure how to group the output from these multiple entities and pass it to my RecyclerViews.

    I've spent the better part of 3 days searching online for answers and code examples but just can't seem to find the answer. I'm confident that the answer is in the official Android developer page but I'm not even sure what to look for at this point.

    If it helps, my existing code is linked below.

    https://github.com/MarleneKotlarz/Kotlarz_Marlene_DogServiceScheduler

    Any guidance that you provide is greatly appreciated.

    submitted by /u/WhoRunDaWorldSqrlz
    [link] [comments]

    No comments:

    Post a Comment