Error in Intent - Android Studio - android

I'm trying to modify vuforia's sample videoplayback application in Android Studio. In that sample app, video will be played whenever targeted image is focused. I try to modify like I want to go next activity when the video is played fully. So I just used Intent, but it will throw and error as "Cannot resolve constructor Intent". Here I have attached screenshot of the error.Can you guys please help me to resolve this issue. Thanks in advance.
Screenshot of the error VideoPlayerHelper imports

Intent intent = new Intent(this, SearchResult.class);
"this" should be context or child's context.
Intent intent = new Intent(type of context, SearchResult.class);

This is just a class you need to pass the context to the class(passing through constructor would be better). Then do following:
Intent intent = new Intent(context,SearchResult.class);
and better way is create listeners(interface) and call appropriate method on activity using them.

Try Intent intent = new Intent(VideoPlayerHelper.this,SearchResult.class);

Just change u're coding
Intent intent = new Intent(this,SearchResult.class);
to
Intent intent = new Intent(getIntent(),SearchResult.class);

Related

How to start an Intent in Android

I just following a tutorial to start a basic intent, and I get an error. Doing exact the same as the tutorial, created an empty Activity and just passed as argument to the intent. What is the problem?
Using a video tutorial: Lynda.com - Developing Android Apps Essential Training (2015)
The error you've got in IDE usually happens when you try to use Activity Context (keyword this) inside some callback, listener or anonymous function. In such situation this does not refer to the Context of the Activity.
That's why solution provided by #Vishal Patoliya should fix your problem because you're explicitly referring to the Context of the concrete Activity as follows:
Intent intent = new Intent(YourActivity.this,ItemUserSettingRattingActivity.class);
Try this
Intent intent = new Intent(YourActivity.this,ItemUserSettingRattingActivity.class);
startActivity(intent);
In case of Activtiy, you are going to another activity:--
Intent intent = new
Intent(YourActivity.this,ItemUserSettingRattingActivity.class);
startActivity(intent);
If you are passing intent from a fragment to open a activity then
Intent intent = new Intent(getActivity(),ItemUserSettingRattingActivity.class);
startActivity(intent);
Have you already created a class named ItemUserSettingRattingActivity.java? maybe you get an error it's because the intent you created didn't detect the class.

android startActivity from intent in service [duplicate]

This question already has answers here:
Start Activity from Service in Android
(10 answers)
Closed 8 years ago.
i try to use intent in service but when i try this :
Intent intent_facebook = new Intent (this,MainUploadToYoutube.class);
intent_facebook.putExtra("vid", vid);
startActivity(intent_facebook);
got this error on logcat :
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
so i tried this from here :
android start activity from service
Intent intent_facebook = new Intent(getBaseContext(), MainUploadToYoutube.class);
intent_facebook.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity( intent_facebook);
but this do nothing and i did not get error in logcat
what wrong ?
Have you tried your own code (using this as context), but just add the flags as the error tells you?
Intent intent_facebook = new Intent (this, MainUploadToYoutube.class);
intent_facebook.putExtra("vid", vid);
intent_facebook.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent_facebook);
this may help
in Service class you get context and initialize with Context mContext
Intent intent = new Intent(mContext,MainUploadToYoutube.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
((Activity)mContext).startActivity(intent);
There is nothing wrong with your code. It should work. Your problem is something else. Make sure MainUploadToYoutube activity is defined in the manifest and app may not crash once this activity is lunched.

calling another project class from another android?

I want to call a class of another project. I added it in the build path and also declared that class in the manifest file but when I call it gives me a no class found error. I am calling it from intent.
Intent intent = new Intent(getApplicationContext(), org.coolreader.CoolReader.class);
intent.putExtra("path", adapter.getItem(position).getPath());
startActivity(intent);
If you want to launch CoolReader from your program than look at this answer:
Intent coolReaderIntent = getPackageManager().getLaunchIntentForPackage("org.coolreader.CoolReader");
coolReaderIntent.putExtra("path", adapter.getItem(position).getPath());
startActivity(coolReaderIntent);
Of course, CoolReader (program) should be installed on the device.

Launch another App within an App for android

I am new to Android. Say, I open an app and I would like to open another App after clicking a button. How can I accomplish this task? Would appreciate if you can provide me some tutorial on this.
Intent intent = new Intent();
intent.setClassName("**package.name**", "**package.name.LauncherActivityName**");
startActivityForResult(intent,REQUEST_CODE);
You need to know the package and class names of the activity to call
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("app package name");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
Use this code:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.example.package");
startActivity(launchIntent);
The app you want to launch must be on the device.
Intent appIntent = getPackageManager().getLaunchIntentForPackage("your app package name ");
startActivity(appIntent );
If the other application is a pre-packaged application mean, this tutorial may help you.
If the other application is going to be your application, then you need to learn Implicit Intent tutorials.
Also include the activity of the other application which you are planning to call in the Manifest file of the calling package also.

No Activity found to handle Intent, Android

I am developing a project on Android that deals with images either from the camera or from the sd-card. I had this working fine until earlier I was fiddling with the code and broke it. It was too late to undo and I can't seem to find the solution.
After the image is selected and processed, a list should be returned but now I get an Activity not Found exception, here is a picture.
If anybody has any idea whats going on I'd appreciate it!
EDIT
Just got it, was a silly mistake, I had
Intent intent = new Intent(Results)
Instead of
Intent intent = new Intent(this, Results.class)
It was a silly mistake, I had
Intent intent = new Intent(Results)
Instead of
Intent intent = new Intent(this, Results.class)
Try adding "" to the calling Activity.

Categories

Resources