How to manage startActivityForResult on Android

In my activity, I’m calling a second activity from the main activity by startActivityForResult. In my second activity, there are some methods that finish this activity (maybe without a result), however, just one of them returns a result. For example, from the main activity, I call a second one. In this activity, I’m checking some … Read more

How can I open a URL in Android’s web browser from my application?

How to open an URL from code in the built-in web browser rather than within my application? I tried this: try { Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link)); startActivity(myIntent); } catch (ActivityNotFoundException e) { Toast.makeText(this, “No application can handle this request.” + ” Please install a webbrowser”, Toast.LENGTH_LONG).show(); e.printStackTrace(); } but I got an Exception: … Read more

Cannot resolve symbol “Intent”

Cannot resolve symbol “Intent” – Read For Learn Skip to content Try the following Rebuilding the project Cleaning the project Syncing with Gradle Files Closing the Project, closing AS and relaunching / reopening File > Invalidate Caches / Restart Double checking all support libraries are up to date in the SDK manager Exit Android Studio … Read more

How to pass an object from one activity to another on Android

One option could be letting your custom class implement the Serializable interface and then you can pass object instances in the intent extra using the putExtra(Serializable..) variant of the Intent#putExtra() method. Pseudocode: //To pass: intent.putExtra(“MyClass”, obj); // To retrieve object in second Activity getIntent().getSerializableExtra(“MyClass”); Note: Make sure each nested class of your main custom class has implemented Serializable interface to avoid … Read more