i want to open a fragment from an other "Application 1" and show it in "Application 2", i know if i want to call an activity i use this code :
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.app1", "com.app1.MainActivity"));
startActivity(intent);
but now i want to use a fragment not activity!
How can i do it please ?
i tried to use
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MainActivity()).commit();
but it didn't work.
Related
I am a noob developer in android who is just learning to experiment with activities and stuff like that. Today I learnt about TextFields, and tried to use a normal plaintext EditText view as a username, a password-input type EditText view, and a button to which an onClick method by the name of "loginMethod" was attached. I used simple if-else statements by taking the inputs in the text fields to string and want to open a new activity when the desired username and password are entered, and to show a toast if not. However, on running the application it only gives the toast message for the error and doesn't start the activity.
The code for the method is attached below:
public void loginMethod(View view)
{
EditText username=(EditText) findViewById(R.id.username);
EditText password=(EditText) findViewById(R.id.password);
String user_name=username.getText().toString();
String pass_word=password.getText().toString();
Log.i("Info","Entered username: "+user_name+" and Entered password: "+pass_word);
Context context=getApplicationContext();
int duration= Toast.LENGTH_LONG;
if (user_name=="myuser" && pass_word == "mypass")
{
Intent i=new Intent(MainActivity.this,welcome.class);
startActivity(i);
}
else Toast.makeText(getApplicationContext(),"Wrong Username or Password!",duration).show();
}
The output when the image is run is also attached in the image below. Please help.
Check out the output screenshot from here
Change this line:
if (user_name.text.toString()=="myuser" && pass_word.text.toString() == "mypass")
I'm working on android development in TC51 with DataWedge API and I want to send the scanned data to different TextView based on the scanning order. But the scanned data always output as keystrokes and always appear in the focused edit text view (which is not the one I target).
I've tried the config to disable the keystroke output through API, but it is not working.
Bundle ksConfig = new Bundle();
ksConfig.putString("PACKAGE_NAME", "KEYSTROKE");
ksConfig.putString("RESET_CONFIG", "true");
Bundle bParams = new Bundle();
bParams.putString("keystroke_output_enabled","false");
ksConfig.putBundle("PARAM_LIST", bParams);
Intent dwIntent = new Intent();
dwIntent.setAction("com.symbol.datawedge.api.ACTION");
dwIntent.putExtra("com.symbol.datawedge.api.SET_CONFIG", ksConfig);
cxt.sendBroadcast(dwIntent);
DataWedge API version: 6.8.50
This one worked for me, EXTRA_PROFILENAME is the name of datawedge profile:
public void disableKeystrokeOutput() {
Bundle configBundle = new Bundle();
configBundle.putString("PROFILE_NAME", EXTRA_PROFILENAME);
configBundle.putString("PROFILE_ENABLED","true");
configBundle.putString("CONFIG_MODE","UPDATE");
Bundle bConfig = new Bundle();
bConfig.putString("PLUGIN_NAME", "KEYSTROKE");
Bundle bParams = new Bundle();
bParams.putString("keystroke_output_enabled","false");
bConfig.putBundle("PARAM_LIST", bParams);
configBundle.putBundle("PLUGIN_CONFIG", bConfig);
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SET_CONFIG", configBundle);
i.putExtra("SEND_RESULT", "true");
i.putExtra("COMMAND_IDENTIFIER", "KEYSTROKE_API");
this.sendBroadcast(i);
}
I want to pass data from Activity1 to Activity2 and then Data of Activity1 and Activity2 combined in Activity3.
how am i supposed to do it Android Studio?
You can use intent extras to do this. Intent extras use a key/value pair system to store data. For example to put data you would say:
String name = "John Doe";
Intent intent = new Intent(this, Activity2.class);
intent.putExtra("myData", name);
startActivity(i);
Then in Activity2, you would retrieve the intent, and then get your data back:
Intent intent = getIntent();
String name = intent.getStringExtra("myData");
Now inside of this variable name, you will find "John Doe"
I want to navigate on previous activity by using onBackPressed(). I tried the following code :
Intent i=new Intent(detail.this,Data.class);
startActivity(i);
It's working, navigating on the Data.java file by manually. But my problem is that instead of Data.class there are other activities according to my need, like
Homepage.class==>Data.class====>detail.class
Homepage.class==>Inbox.class====>detail.class
Homepage.class==>Information.class====>detail.class
means like this,
For 1st condition
Intent i = new Intent(detail.this, Data.class);
startActivity(i);
For 2nd condition
Intent i = new Intent(detail.this, Inbox.class);
startActivity(i);
For 3rd condition
Intent i = new Intent(detail.this, Information.class);
startActivity(i);
Now my question is: how to know the previous activity class name and how to replace the class name data.class in following line automatically
Intent i = new Intent(detail.this, Data.class);
I am using Monotouch to write an Ipad app. The app uses tables to browse down through a directory tree and then select a file. I have used Monotouch.Dialog to browse the directories and I set up the directory tables as the app starts.However there are too many files to set up in a table as the app starts and so I want to set up the 'file table' as the file is selected from the lowest level directory table. I am trying to use LoadMoreElement to do this but I cannot make it work or find any examples online. I have coded the 'Elements API Walkthrough' in the Xamarin tutorial at:- http://docs.xamarin.com/ios/tutorials/MonoTouch.Dialog
I then add a new section to the code:-
_addButton.Clicked += (sender, e) => {
++n;
var task = new Task{Name = "task " + n, DueDate = DateTime.Now};
var taskElement = new RootElement (task.Name){
new Section () {
new EntryElement (task.Name,
"Enter task description", task.Description)
},
new Section () {
new DateElement ("Due Date", task.DueDate)
},
new Section()
{
new LoadMoreElement("Passive","Active",
delegate {MyAction();})
}
};
_rootElement [0].Add (taskElement);
Where MyAction is:-
public void MyAction()
{
Console.WriteLine ("we have been actioned");
}
The problem is that MyAction is triggered and Console.Writeline writes the message but the table stays in the active state and never returns to passive. the documentation says:-
Once your code in the NSAction is finished, the UIActivity indicator stops animating and the normal caption is displayed again.
What am I missing?
Ian
You need to set the "Animating" property in the element to false.
Like this:
LoadMoreElement loadMore = null;
loadMore = new LoadMoreElement (
"Passive", "Active",
delegate {loadMore.Animating = false;});
Where did you see any documentation that says that the animation stops when the delegate stops running? If that is documented anywhere, that is wrong.