I have one activity in one application, which is supposed to run another activity in another application, while passing to it an arguments|(Through putExtra)
The problem is that I know that I must add something like:
Intent i = new Intent(target);
i.setAction("actionstring" + System.currentTimeMillis());
to the target intent(activity) so the system wont override the Extra's and ill get diffrent extra's each time i run the target activity.
But when i add the setAction i get an error:
couldnt find activity: No Activity found to handle Intent { action=actionstring1278829343752 flags=0x10000000 (has extras) }
Any idea how could I solve it with setAction? maybe something I have to add also to the manifest?
You can not use setAction for what you're trying to achieve, you must use [putExtra][1].
[1]: http://developer.android.com/reference/android/content/Intent.html#putExtra(java.lang.String, java.lang.String[])
try First Activity:
Intent intent = new Intent(getApplicationContext,SecondActivity.class);
intent.putExtra("KEY",value);
intent.putExtra("KEY",VALUE);
startActivity(intent)
Second Activity:
Intent intent =getIntent();
confirm_txt =(TextView)findViewById(R.id.txt);
String txt_put =intent.getStringExtra("KEY");
confirm_tId.setText(txt_put);
Related
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.
How can i launch an AndroidAnnotations Activity_ inside of an App (main)
since external Activity (another App).
this is my current code:
Intent codeScannerActivity = new Intent(PACKAGE, CODE_SCANNER_ACTIVITY);
codeScannerActivity.putExtra("codeScannerType", CameraUtils.CODE_SCANNER_SINGLE);
startActivityForResult(codeScannerActivity, Core.ActivityResult.RequestCode.CODE_SCANNER);
where PACKAGE = "main.app.package"
and CODE_SCANNER_ACTIVITY = PACKAGE + ".activity.MyActivity_"
but logs throws:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=main.app.package dat=main.app.package.activity.MyActivity_ (has extras) }
Activity is defined in the Manifest's Main App with the Class "etc.MyActivity_".
You are constructing the Intent incorrectly. For the constructor you are using, the first parameter is interpreted as an "action" and the second as a URI. The error says that there is no activity which can respond to the action "main.app.package" and the URI "main.app.package.activity.MyActivity_".
To fix the problem, first read Starting Another Activity and the Intent javadocs from the Android Developer site. Especially look at the documentation for the available constructors. There might be one more appropriate for your purposes than the one you are trying to use. The Intent documentation has a list of standard Activity actions. If you want to start a specific activity, you should use Intent (Context packageContext, Class<?> cls):
Intent intent = new Intent(this, main.app.package.activity.MyActivity_.class);
I was creating wrong the Intent, this is the right way:
Intent codeScannerActivity = new Intent();
codeScannerActivity.setComponent(new ComponentName(PACKAGE, CODE_SCANNER_ACTIVITY));
codeScannerActivity.putExtra("codeScannerType", CameraUtils.CODE_SCANNER_SINGLE);
startActivityForResult(codeScannerActivity, Core.ActivityResult.RequestCode.CODE_SCANNER);
Form Activity Login I call
Intent intent=new Intent(LogIn.this,BRInfoActivity.class);
From Activity BrActivityList I Call
Intent intent=new Intent(BRActiviList.this, BRInfoActivity.class);
intent.putExtra("BRinfo", objBR);
And Now in BRInfoActivityList
Intent i = getIntent();
BrInfoEN objBR=(BrInfoEN)i.getSerializableExtra("BRinfo");
Now i want if(intent==BrActivityList)The last two above line execute otherwise does not.How to do it?
If you will start activity with
startActivityForResult().
Then you can use getCallingActivity() to get caller.
Form Activity Login call this--
Intent intent=new Intent(LogIn.this,BRInfoActivity.class);
intent.putExtra("call_from","ActivityClass");
From Activity BrActivityList Call--
Intent intent=new Intent(BRActiviList.this, BRInfoActivity.class);
intent.putExtra("call_from", "BRActivity");
Now, when you get the intent, compare the "call_from" string in an if-else block! That's it!
May this help you...
The new intent comes as part of onNewIntent(Intent). The original Intent is still available via getIntent().
You put whatever code you need to into onNewIntent in order to update the UI with the new parameters; probably similar to what you're doing in onCreate.
Also, you probably want to call setIntent(intent) in onNewIntent to make sure future calls to getIntent() within the Activity lifecycle get the most recent Intent data.
How can I extract all information about an intent? Like action, extras, bundles etc.
Intent intent = getIntent();
Log.d(Tag.getTag(this), (/*What shall I add here?*/));
intent.getAction(), intent.getData(), intent.getExtras(), and maybe others. All of these are documented in the Intent class.
If you are using toString() method, you can see something like,
Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.test/.TestDeleteActivity }
What I suggest is, if you want details about your running Intent, use the appropriate methods. As an example by using getPackage() method you can retrieve the application package name this Intent is limited to. The documentation contains all the methods you can use with Intent class.
If you want to pass some data from one Intent to another, use the Bundle class. This link will show you a simple example of how to use Bundle class.
Not sure how to explain this,hope you understand me.. Here is the problem :
I have a few packages in my app and I'm doing this :
Intent intent = new Intent(view.getContext(), com.example.app.Lol.class);
startActivity(intent);
and his code is in class which is in package : com.example.anotherone
It's not possible as I saw, that's why I'm asking..what I have to do, so I can be able to create an Intent like the example above.
Thanks anyway!
Make sure you are importing the class you want
import com.example.anotherone.Classname;
and pass Classname.class in your intent,
Intent intent = new Intent(view.getContext(), Classname.class);
And that your Manifest is updated with the correct name for the activity (com.example.anotherone.Classname).
If you want to start an activity from another application, you can do it by specifying the intent action. When you define the activity you want to start in its application Manifest file, you can set it's <action/> tag inside <intent-filter/> to whatever action you want. Then to start this activity from another application call
Intent intent = new Intent("your-action-name");
startActivity(intent);
Your application will be the only to answer on this action request and it will open. Hope this helps.
1.At first import the class you want.
2.pass the class name with intent.
For example:
import package.otherclassname.yourclassname;
Intent intent=new Intent(view.getContext(),yourclassname.class);