Use
Intent myIntent = new Intent(v.getContext(), MyClass.class);
or
Intent myIntent = new Intent(MyFragment.this.getActivity(), MyClass.class);
to start a new Activity. This is because you will need to pass Application or component context as a first parameter to the Intent Constructor when you are creating an Intent for a specific component of your application.
Related Posts:
- Android – Adding at least one Activity with an ACTION-VIEW intent-filter after Updating SDK version 23
- How to use putExtra() and getExtra() for string data
- How do I get the dialer to open with phone number displayed?
- Parcelable encountered IOException writing serializable object getactivity()
- Sending an Intent to browser to open specific URL
- Android : When do we use getIntent()?
- setOnClickListener error – cannot resolve symbol
- What is the meaning of android.intent.action.MAIN?
- How can I open a URL in Android’s web browser from my application?
- How do I get the currently displayed fragment?
- Android Overriding onBackPressed()
- Android: No Activity found to handle Intent error? How it will resolve
- What exactly is “com.google.android.packageinstaller”
- How to use adb command to push a file on device without sd card
- Exception : AAPT2 error: check logs for details
- This adb server’s $ADB_VENDOR_KEYS is not set
- Exception : AAPT2 error: check logs for details
- Android ADB devices unauthorized
- adb is not recognized as internal or external command, operable program or batch file
- Getting net::ERR_UNKNOWN_URL_SCHEME while calling telephone number from HTML page in Android
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- Still getting warning : Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’
- java.lang.NullPointerException: Attempt to invoke virtual method on a null object reference
- because an app is obscuring a permissions request, Settings can’t verify your response
- Android: adb pull file on desktop
- ADB No Devices Found
- RecyclerView vs. ListView
- How do I remove the title bar from my app?
- What does getActivity() mean?
- Session ‘app’: Error Installing APK
- Force a default browser on my android phone using a simple html shortcut page
- adb shell su works but adb root does not
- MediaStore.Images.Media.insertImage deprecated
- How to update Notification with RemoteViews?
- How to fix: Error device not found with ADB.exe
- How to create a popup window (PopupWindow) in Android
- findViewById in Fragment
- ImageView in circular through XML
- Intel HAXM is required to run this AVD
- Unsupported method: BaseConfig.getApplicationIdSuffix()
- No Sound coming from Android Emulator [duplicate]
- Font size of TextView in Android application changes on changing font size from native settings
- Android: How to handle right to left swipe gestures
- No tests found for given includes Error, when running Parameterized Unit test in Android Studio
- Could not identify launch Activity: Default Activity not found
- Android: Difference between Parcelable and Serializable?
- Adding an onclicklistener to listview (android)
- Android – Listen For Incoming SMS Messages
- What does “Failure [INSTALL_FAILED_OLDER_SDK]” mean in Android Studio?
- How to give persiomission com.sec.android.provider.badge.permission.READ or WRITE in android 6.0
- How to make a round button?
- java.lang.RuntimeException: Unable to start activity ComponentInfo
- Android LinearLayout Gradient Background
- Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat
- Why emulator is very slow in Android Studio?
- Android Studio SDK location
- How to create listview onItemclicklistener
- Android Studio-No Module
- Application Installation Failed in Android Studio
- What is INSTALL_PARSE_FAILED_NO_CERTIFICATES error?
- How to convert int to Integer
- Android Studio 3.0 Execution failed for task: unable to merge dex
- What does ellipsize mean in android?
- Is there a way to get the source code from an APK file?
- Android Fragment onAttach() deprecated
- ViewText in Android
- Android SDK location should not contain whitespace, as this cause problems with NDK tools
- Login Error: There is an error in logging you into this application. Please try again later
- ‘dependencies’ cannot be applied to ‘(groovy.lang.Closure)’
- How to emulate a gyroscope in an Android Emulator
- Fullscreen Activity in Android?
- Call to getLayoutInflater() in places not in activity
- How to add a jar in External Libraries in Android Studio?
- Adb backup does not work
- What is the difference between gravity and layout_gravity in Android?
- Remove Project from Android Studio
- Error inflating class android.support.design.widget.FloatingActionButton
- How to change the color of a button?
- How do I parse JSON in Android?
- Cannot resolve symbol ‘AppCompatActivity’
- Change the project theme in Android Studio?
- setBackgroundDrawable() deprecated
- How to implement a confirmation (yes/no) DialogPreference?
- Your CPU does not support VT-x
- Android Studio Gradle DSL method not found: ‘android()’ — Error(17,0)
- Cannot resolve symbol ‘AppCompatActivity’
- Android Studio – Emulator – eglSurfaceAttrib not implemented
- INSTALL_FAILED_NO_MATCHING_ABIS when install apk
- Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
- Start an activity from a fragment
- HAXM is not installed on this machine
- Android: remove or disable programmatically the Lock Screen on Samsung Galaxy S2 device
- How to convert a Drawable to a Bitmap?
- How to Resize a Bitmap in Android?
- What to use instead of “addPreferencesFromResource” in a PreferenceActivity?
- How to code using android studio to send an email
- HAX kernel module is not installed
- Could not find method android() for arguments
- Cannot resolve symbol AppCompatActivity – Support v7 libraries aren’t recognized?
- WordPress post to android