I am completely new to Android Studio and just learned Object-oriented programming. My project requires me to build something on open-source code. I added a new menu item to a menu and want to start another activity once the user clicks the menu item with id: plot. The intent will be sent from if (id == R.id.plot) within onOptionsItemSelected(MenuItem item)
Tag: android-activity
Best practice: weak reference to activity in static method
I need to reference an activity in several static methods. I’m curious to know the best practices to avoid memory leaks. Let’s use examples: Example 1: Example 2: So three questions: Do example 1 or 2 make any difference? I haven’t seen methods being called this way much outside of subclasses of Thread or AsyncTask. Any reason why? Am I
How to covert vw measurement to dp in android?
Android Studio Code Snippet I have an android device that has it’s maximum width and height specified in dp units. Max Width – 1079 dp Max Height – 399 dp I want to create a LinearLayout that has to be present vertically and horizontally centered with its height to be in wrap_content length and width to occupy 50vw units. I
How to open recent avtivity after app reopen in android studio
How to open recent activity after app reopen in android studio For Example, we create a book application Then after reopening the app, open the last page where we are Answer Create a Default activity as a launcher activity `public class Default extends AppCompatActivity { }` //In MainActivity while saving preferences use: `public class MainActivity extends AppCompatActivity { }` //In
On Activity App Bar back pressed go to the parent activity with the fragment it was called
I’m having an issue that maybe is happening to other community members and I wanted to ask if somebody knows the solution. I have an app with these Two activities (MainActivity, UserProfileActivity). The MainActivity contains a NavigationDrawer that navigates through fragments. So here it’s the problem. While navigating in the second fragment and pressing a button in that fragment. It
Hilt :- Not able to use the @AndroidEntryPoint in the AppCompatActivity getting DefaultV iewModelFactories exceptions?
I want to use the Hilt in my project for getting the helper class object as the common for my activity. I have tried the below lines of code for it Manifest file entry My AppController class Please check my gradles file for it Please check my classPath entry below Now please check my NVModule Module class in which i
Activity or Fragment for a SearchView?
I´m doing my final degree project and I have chose to develop and Android app using Firebase Firestore, the idea it´s cool because I´m learning how to program on Android, but on Java. So, I have develop the SplashScreen, Login form, SignIn form and able to connect succesfully with Firebase but right now I´m having a problem about thinking the
java.lang.IllegalArgumentException: Ilegal value, when I try to pass object via bundle
I’m trying to pass an object from the class “Transfer” (java) to the class “Limit” (Kotlin), if I try to get the values that come through the “Bundle” using data.name, the compiler does not give an error, but when I enter in the activity of this problem, how can I get an object via Bundle () in my intent? OUTPUT
Using Intent.createChooser and getting error: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag
I want to open the share via option from the service class. It is working fine in Android 7, but in 8+ OS it starts showing android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? I have also included this flag to my Intent, but it’s still showing the same
Getting the current User information from Firebase Realtime Database
I developed a login app in Java where the user can login using their emailaddress and password. This works fine so far, but I have the problem that my UserModel.java is null when I get to my home activity. This also makes sense to me since Firebase Auth only checks the email and password and does not select the relevant