I created an unity project and I'm trying to send data from c# to unity. on my c# code I implemented this code :
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
jo.Call("shareText","test","test");
It works on android on my activity :
public class UnityActivity extends AppCompatActivity {
public void shareText(String AppId,String PublisherID) {
Log.e("test","test");
Log.e("test",AppId);
Log.e("test",PublisherID);
}
}
but in another case I created a custom view containing unityPlayer.
So now I have UnityActivity containing UnityView (which is a java class) and the last one contain my custom view (extend linearLayout) with unityPlayer and with the same code it didn't work :
public class CstUnityView extends LinearLayout {
private UnityPlayer mUnityPlayer;
public void shareText(String AppId,String PublisherID) {
Log.e("test","test");
Log.e("test",AppId);
Log.e("test",PublisherID);
}
}
Anyone have an idea why it didn't work ?!
So your problem is that the shareText() in your custom linearlayout cannot be called by unity unless it is declared in activity. It needs to be declared in your activity in order for your unity Call to ignite the function.
You can check the console log first to make sure it has been called.
After, you can use those that you have received from your activity to your custom layout view.
in your activity
protected UnityPlayer mUnityPlayer;
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//this creates unityplayer with context to your activity
mUnityPlayer = new UnityPlayer(this);
//this requests focus so that the currentactivity is set to your activity
//that is why shareText() can be called from your Unity
mUnityPlayer.requestFocus();
//call layout here
yourLinearlayout customlayout = new yourLinearLayout();
//do what you want to do with this customlayout
//....
}
public void shareText(String AppId,String PublisherID) {
Log.e("test","test");
Log.e("test",AppId);
Log.e("test",PublisherID);
}
Related
I am a student and a beginner in java and android.
I am modifying an android application which allows to configure bluetooth beacons. With the original application we can only configure the beacons one by one, therefore I want to modify the application to be able to configure a good number automatically.
I have a problem when I want to modify an element in the layout of a class from another class.
From the Main class I can interact well with the elements of the Main layout. But since the Main class, I can't interact with other layouts (PasswordDialog in my case). I've been struggling for several days, I tried responses to similar posts but without success because the configuration of my classes is quite special and I don't want to modify them too much so as not to alter the functioning of the application. If anyone has any leads, I would be very grateful;)
The main class:
public class MainActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener, MokoScanDeviceCallback, AdapterView.OnItemClickListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// ...
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// ...
final PasswordDialog dialog = new PasswordDialog(this); // Another function which already calls the PasswordDialog class which interests me
dialog.setSavedPassword(mSavedPassword);
dialog.setOnPasswordClicked(new PasswordDialog.PasswordClickListener() {
// ...
}
}
#OnClick({R.id.iv_about, R.id.iv_refresh, R.id.bt_auto})
public void onClick(View view) {
switch (view.getId()) {
// ...
case R.id.bt_auto: // When I click on the bt_auto button, the code below is executed
final PasswordDialog dialog = new PasswordDialog(this);
dialog.AutoSetPassword("Moko4321"); // the method I'm trying to launch
// ...
}
}
// ...
}
Now here is the PasswordDialog class which is in another package. I want to modify an element of the passworddialog layout from my Main class :
public class PasswordDialog extends BaseDialog {
#Bind(R.id.et_password)
EditText etPassword; // The element that I want to modify
public PasswordDialog(Context context) {
super(context);
}
// ...
public void AutoSetPassword(String pass) { // My method to modify the EditText
etPassword.setText(pass); // This does not work
// and
((EditText) findViewById(R.id.et_password)).setText(pass); // If I try this instead, it's the same
}
}
Thank you so much for your help :)
I've searched for a solution for my question all over the internet but I haven't been able to find one and I hope you can help me out
I am trying to create a master detail flow application in android with 2 activities and the second activity contains a fragment. Can anyone please tell me how I can simultaneously update the value in the MainActivity() when I make a change in the fragment's EditText field? I have tried using an Intent but when the 2 activities are side by side that doesnt seem to work well.
Screenshot of Emulator
Any suggestions?
It seems you are in a context as follows:
When A happens, it triggers B
As a result, I suggest you to use EventBus library in your project.
The installation is easy. First, add the following code in your build.gradle file:
compile 'org.greenrobot:eventbus:3.0.0'
Second, let's see what we are going to add in our codes.
In the Fragment which you wanted to make changes:
/* When A happens */
myButton.setOnClickListener(new View.OnClickListener() { // complete entering the content, update it
EventBus.getDefault.post(MyUpdateEvent(myContent));
});
Create your custom class MyUpdateEven:
public class MyUpdateEvent{
private String myContent;
public MyUpdateEvent(String myContent) {
this.myContent = myContent;
}
public String getUpdateContent() {
return myContent;
}
}
In the Activity you wanted to update:
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EventBus.getDefault.register(this); // add this code to monitor the update
}
/* It triggers B */
#Subscribe // don't forget to add #Subscribe
public void onEvent(MyUpdateEvent event){
// this is your custom method
myTextView.setText(event.getUpdateContent()); // do your update
}
#Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault.unregister(this); // when you leave this lifecycle, cancel the monitoring
}
}
EventBus is a good library that I've been used a lot in my projects.
I think it can solve your problem.
Try to define a interface.
public interface OnEditActivity {
public void onEdit(ActivityObject activityObject, boolean isEditing);
}
And on your another class for example DetailActivity, then you have to override the method onEdit that you created in your interface:
public class DetailActivity extends AppCompatActivity implements OnEditActivity{
//IN HERE --- Create method.
#Override
public void onEdit(ActivityObject activityObject, boolean isEditing) {
if(isEditing){
displayView(activityObject,true);
}else{
displayView(activityObject,false);
}
}
}
And in your EditFragment for example will look like this:
public class EditFragment extends Fragment{
//Define your interface in your fragment
private OnEditActivity onEditActivity;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_edit_activity, container, false);
return v;
}
public void onAttach(Activity a) {
super.onAttach(a);
onEditActivity =(OnEditActivity) a;
}
}
And if you want to call onEdit method just call:
onEditActivity.onEdit(activityObjectNew,false)
I hope this help you !
Before i start, i have look through question such as:
Passing data between fragments: screen overlap
How to pass values between Fragments
as well as Android docs:
http://developer.android.com/training/basics/fragments/communicating.html
as well as this article:
http://manishkpr.webheavens.com/android-passing-data-between-fragments/
Though all the cases mentioned above similar to what i have, it is not entirely identical. I followed a good tutorial here (Some portion of my code is based on this article):
http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/
I have the following files:
RegisterActivity.java
NonSwipeableViewPager.java
ScreenSliderAdapter.java
RegisterOneFragment.java
RegisterTwoFragment.java
And the following layouts:
activity_register.xml
fragment_register_one.xml
fragment_register_two.xml
What i am trying to achieve is passing an Serializable object from RegisterFragmentOne to RegisterFragmentTwo.
So far this is what i have done (some codes are omitted):
RegisterActivity.java
public class RegisterActivity extends FragmentActivity
implements RegisterOneFragment.OnEmailRegisteredListener{
public static NonSwipeableViewPager viewPager;
private ScreenSliderAdapter mAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
// Initilization
mAdapter = new ScreenSliderAdapter(getSupportFragmentManager());
viewPager = (NonSwipeableViewPager) findViewById(R.id.pager);
viewPager.setAdapter(mAdapter);
}
public void onEmailRegistered(int position, Registration regData){
Bundle args = new Bundle();
args.putSerializable("regData", regData);
viewPager.setCurrentItem(position, true);
}
}
ScreenSliderAdapter.java
public class ScreenSliderAdapter extends FragmentPagerAdapter{
public ScreenSliderAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int index) {
switch (index) {
case 0:
return new RegisterOneFragment();
case 1:
return new RegisterTwoFragment();
case 2:
return new RegisterThreeFragment();
}
return null;
}
#Override
public int getCount() {
return 3;
}
}
NonSwipeableViewPager.java (extending ViewPager class, and overrides the following)
#Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
// Never allow swiping to switch between pages
return false;
}
#Override
public boolean onTouchEvent(MotionEvent event) {
// Never allow swiping to switch between pages
return false;
}
RegisterOneFragment.java
public class RegisterOneFragment extends Fragment {
OnEmailRegisteredListener mCallBack;
public interface OnEmailRegisteredListener {
/** Called by RegisterOneFragment when an email is registered */
public void onEmailRegistered(int position, Registration regData);
}
public void onAttach(Activity activity){
super.onAttach(activity);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception.
try {
mCallBack = (OnEmailRegisteredListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnEmailRegisteredListener");
}
}
... And some to execute some HTTP request via separate thread...
}
What i am trying to accomplish is that when ever a user pressed a button on RegisterOneFragment, a data will be sent to a server (and returns some validation over JSON). If the returned data is valid, the the application should go to the next fragment which is RegistrationTwoFragment.
I am having some confusion as how to pass objects between fragments, since my Fragments is created using an Adapter. And that Adapter is then attached to my Activity.
Can anyone help me with this? Thx
Edit 1:
I tried to make a shortcut (unfortunately does not work) like so:
In RegisterActivity i created:
public Registration regData;
and in RegisterOneFragment:
/* PLACED ON POST EXECUTE */
((RegisterActivity)getActivity()).regData = regData;
Finally called it in RegisterTwoFragment
Registration regData;
regData = ((RegisterActivity) getActivity()).regData;
It throws a nullPointerExceptions
Edit 2
Just to be clear, RegisterActivty contains multiple fragments. And the only way user can navigate between fragment is by clicking a button. The Activity has no Tab bar.
It's easy to share objects via implementing Serializable to your custom Object. I wrote a tutorial about this here.
From Fragment One:
android.support.v4.app.FragmentTransaction ft =
getActivity().getSupportFragmentManager().beginTransaction();
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
OfficeCategoryFragment frag = new OfficeCategoryFragment();
Bundle bundles = new Bundle();
Division aDivision = divisionList.get(position);
// ensure your object has not null
if (aDivision != null) {
bundles.putSerializable("aDivision", aDivision);
Log.e("aDivision", "is valid");
} else {
Log.e("aDivision", "is null");
}
frag.setArguments(bundles);
ft.replace(android.R.id.content, frag);
ft.addToBackStack(null);
ft.commit();
In Fragment two:
Bundle bundle = getArguments();
Division division= (Division) bundle.getSerializable("aDivision");
Log.e("division TEST", "" + division.getName());
I would normally have setters or methods similar to this in the containing activity.
So if I understand correctly, you want the user to access RegistrationOneFragment, then when completed, use this data, validate it, and if valid, pass it along to RegistrationTwoFragment and move the user to this Fragment.
Could you simply call validateJson(regData) in your onEmailRegistered method to handle the validation in your activity, if it succeeds, commit a transaction to RegistrationTwoFragment.
Then all you need are getters and setters in your activity or Fragment to say getRegistrationOneData() in the activity or setData(Registration args) in the fragment as your examples show above.
I don't know of any way to pass the args directly into the Fragment.
I found a solution to my question, which i am sure not the correct way to do that...
So in RegisterActivity.java i add + modified the following lines (thx to #sturrockad):
public Registration getRegistrationData(){
return this.regData;
}
public void onEmailRegistered(int position, Registration regData){
this.regData = regData;
viewPager.setCurrentItem(position, true);
}
Then in RegisterTwoFragments.java (or in the Fragment to which i want to receive the Object):
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_register_two, container, false);
regData = ((RegisterActivity) getActivity()).getRegistrationData();
...
I used to set object with Pacelable or Serializable to transfer, but whenever I add other variables to object(model), I have to register it all. It's so inconvenient.
It's super easy to transfer object between activities or fragments.
Android DataCache
put your data object to KimchiDataCache instance in your activity or fragment.
User userItem = new User(1, "KimKevin"); // Sample Model
KimchiDataCache.getInstance().put(userItem);
// add your activity or fragment
Get your data object in your activity of fragment that you added.
public class MainFragment extends Fragment{
private User userItem;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
userItem = KimchiDataCache.getInstance().get(User.class);
}
I want to implement a splash screen into my app. I already did this. But at the moment it just waits 3 seconds and then calls the MainActivity class. The problem with that is that i have data to load and with the current setup the user have to waits two times. I want a splash screen that loads all the data. I have a MainActivity class where everything happens and I have my SplashScreen class.
The method I want to be run in the background is in my MainClass. So basically I have my splash screen class like that
public class SplashScreenActivity extends AsyncTask<Void, Void, Void> {
#Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
return null;
}
protected void onPostExecute(Void... params) {
// TODO Auto-generated method stub
}
protected void onCancelled() {
// TODO Auto-generated method stub
}
}
I also implemented but not copied the imports and packages, so that shouldn't be a problem. Now, if I understood correctly I need to write the task that should be done into the doInBackground method. So I basically have to call the method from my other activity class, right?
public MainActivity mA = new MainActivity();
and then in the method I would write mA.parseXMLfromURL();
And afterwards I would start an intent of the main class into the onPostExecute-method like this?
protected void onPostExecute(Void... params) {
Intent mainClass = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(mainClass);
}
If more information is needed I will gladly elaborate further.
UPDATES
Well, after your comments I tried it a bit differently.
This is my oncreate method
public void onCreate(Bundle savedInstanceState) {
StrictMode.setThreadPolicy(policy);
super.onCreate(savedInstanceState);
sv = new ScrollView(this);
layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
sv.addView(layout);
setContentView(sv);
new SplashScreenActivity().execute("URL TO FILE");
}
And this is the SplashScreenActivity
public class SplashScreenActivity extends AsyncTask<String, Void, Void> {
public MainActivity mA = new MainActivity();
protected void onPostExecute(Void... params) {
}
protected void onCancelled() {
// TODO Auto-generated method stub
}
#Override
protected Void doInBackground(String... params) {
mA.parseXMLfromURL(params);
return null;
}
}
But this just returns a blank screen. However if I call the parseXMLfromURL in my main activity it works just fine.
#Raghunandan said in comments that I wrongly created the instance of the class. Would be glad if you could elaborate your answer.
UPDATE NUMBER TWO
Current SplashScreen-Code is the following:
package de.activevalue.T1000flies;
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
public class SplashScreenActivity extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
new mTask().execute();
}
private class mTask extends AsyncTask<Void, Void, Void>{
MainActivity mA = new MainActivity();
#Override
protected Void doInBackground(Void... arg0) {
mA.parseXML();
return null;
}
protected void onPostExecute(Void... params){
Intent i = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(i);
finish();
}
}
}
With that code the app just stucks at the Splash-Screen. It seeems like there is a problem with my XML-Parsing. Here is the XML-Parsing-code. Note that it works without any problems, when I just start the main activity wihtout the splash screen
UPDATE NUMBER THREE
I just started to debug by making breakpoints line per line. It jumps out at this line
rankingDate [k] = new TextView(this);
Rest of the code
for(int k = 0; k < metaList.getLength(); k++){
Node metaNode = metaList.item(k);
System.out.println(metaList.getLength());
rankingDate [k] = new TextView(this);
rdate [k] = new TextView(this);
numberOE [k] = new TextView(this);
Element metaElement = (Element) metaNode;
NodeList rankingDateList = metaElement.getElementsByTagName("date");
Element rankingDateElement = (Element) rankingDateList.item(0);
rankingDateList = rankingDateElement.getChildNodes();
rankingDate [k].setText("RankingDate: " + ((Node) rankingDateList.item(0)).getNodeValue());
layout.addView(rankingDate[k]);
xmlSerializer.startTag(null, "date");
xmlSerializer.text(((Node) rankingDateList.item(0)).getNodeValue());
xmlSerializer.endTag(null, "date");
}
The system.out.println gives me 1. And k is 0. So why is it a Null Pointer Exception?
You should create new activity for SplashScreen --> SplashScreenActivity extends Activity, declare in manifest and than set layout ;
public SplashScreenActivity extends Activity{
protected void onCreate(Bundle ...){
super.onCreate(...);
setContentView(...);
new mTask().execute();
}
private class mTask extends AsyncTask<Void, Void, Void>{
#Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
return null;
}
protected void onPostExecute(Void... params) {
Intent mainClass = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(mainClass);
finish();
}
}
}
Piggy-backing off nurisezgin's answer explaining how AsyncTasks work in android, you're almost there but need to get some other things out of the way.
First: In Android-world, you never initialize activities by calling their constructor. Activities are handled by the operating system, and you run them using Intents.
That out of the way, you're very close to having your issue solved. You need to take whatever code is in the parseXML function of your MainActivity and put it either into your SplashScreenActivity and call it, or just put it directly in your doInBackground method.
Your doInBackground method should not be calling any outside activities.
An easier way to do your splash screen is to have it appear in front of your main activity that needs to load data using Dialogs. The easiest way to go about this is to override the onPreExecute() method in AsyncTask. The following is a simple example of a splash screen.
MainActivity.java
public class MainActivity extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new SplashScreen(this).execute();
}
}
SplashScreen.java
public class SplashScreen extends AsyncTask<Void, Void, Void>
{
Context ctxt;
Dialog splash;
public SplashScreen(Context ctxt)
{
this.ctxt = ctxt;
}
protected void onPreExecute()
{
splash = new Dialog(ctxt, R.style.full_screen);
splash.show();
}
protected Void doInBackground(Void... ignore)
{
//Fetch stuff
return null;
}
protected void onPostExecute(Void ignore)
{
splash.dismiss();
}
}
In your res/values/styles.xml file, you want to put the following xml for full screen.
<!-- Stuff that's already in here -->
<style name="full_screen" parent="android:Theme.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<!-- Stuff that's already in here -->
This will give you a very basic splash screen (i.e., a blank screen that says nothing). If you look into the Dialogs API, you can find other ways to customize it that allow you to use pictures instead of text as well as completely customize the layout of the Dialog. Also look into DialogFragments if you want an even further customization. The benefit of doing your splash screen this way is that you can retrieve all of your information and set it up in the onPostExecute() to your MainActivity without having to worry about transferring the data.
Hope this helps! Good luck.
I tried exactly the same in a project, but my approach was different. Maybe it`could solve your problem as well...
first, my SplashScreen was an overlay in the MainActivity
//main-activtiy xml
<RelativeLayout ...
<RelativeLayout id="overlay" visible="true"... //filled parent and had a centered image
<RelativeLayout id="mainActivity" visible="false"... //the application
Application launched
Start your AsyncTask or Service in your onCreateMethod
if data is loaded, send Notification to your MainActivity and "swap your view" like
public void functionCalledOnDataLoaded(){
//do you init stuff
((RelativeLayout) findViewById(R.id.overlay)).setVisibility(View.INVISIBLE);
((RelativeLayout) findViewById(R.id.mainActivity)).setVisibility(View.VISIBLE);
}
Why don't you only create MainActivity. The Splash is just a frame layout of main.xml, and will be setVisibility(View.GONE) after certain time.
Using this method, you have only 1 activity. Thus, it's easier to handle load data from network without interrupt.
I am newbie in android, in my android app, a main Activity class, which contains a TextView for displaying various status message from other classes. I want to update TextView of main Activity with status values from other classes. There is no direct connection between main activity class and other class. Is it possible in android ? if yes i am not aware to do it. Kindly provide solution to do it
code snippets
//main activity
public class MainMenu extends Activity {
static String status = "Hello Friends";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView)findViewById(R.id.mytext);
tv.setText(status);
MyOtherClass myclass = new MyOtherClass();
myclass.connect();
}
Other class is not an activity class
// Other class
public class MyOtherClass {
public MyOtherClass(){
}
public void connect(){
String strIP = Mtx.confRead("IPAddress");
String strPort = Mtx.confRead("Port");
String msg = "Connecting...";
// i want to show value of msg varible in Textview of main activity from here
}
thanking you
Make a status instance field in your main activity
public static status = "initial status";
set it to the TextView
TextView tv = (TextView) findViewById(R.id.youtTextViewId);
tv.setText(status);
and update it using values in other activities when they are called.
Yes it is possible you need to pass those status values from other classes and then use
textView.setText(your_status);
values can be passed via intents through putExtra() and getExtra()
in first class send status like this
s=new Intent(this, nextClassName.class);
d=new Bundle();
d.putString("status", status);
s.putExtras(d);
startActivity(s);
then in the newClassName u can get it by this code
Intent t=getIntent();
k=t.getExtras();
status=k.getString("status");
the u can set Text of textview to status
textview.setText(status);
try this
u can do this by making these changes in your code
public String connect(){
String strIP = Mtx.confRead("IPAddress");
String strPort = Mtx.confRead("Port");
String msg = "Connecting...";
return msg;
// i want to show value of msg varible in Textview of main activity from here
}
and in main class
String status=myclass.connect();
textview.setText(status);
try this
if the other classes are activities that are started by ur activity, then use something like this
Main Activity
private void some_function() {
startActivityForResult(intent_to_pass, SOME_REQUEST_CODE);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if((requestCode == SOME_REQUEST_CODE) && (resultCode == RESULT_OK)) {
// extract status from data and use setText() to set the new status
}
}
Other Activity
// Prepare an intent, say result, with the status to be sent to main activity and use this to send back the new status
setResult(RESULT_OK, result);
If the other classes are services and/or activities that are independent, then in Main Activity, use
#Override
protected void onNewIntent(Intent intent) {
// Extract new status from intent now and use it
}
In the other classes, simply start the main activity with an intent containing the new status. This ensures that if the main activity is already running, simply use the data in new intent received
EDIT (saw ur updates after posting):
if the other class is neither an activity nor a service, then u can do this:
when u create this class, pass the context of parent class (which can either be a service or an activity) to it and use this context to create an intent which is used with startActivity(). Or, simply communicate using BroadcastListeners. But i m not sure if this is the best way to do it
May be this could work.......
//main activity
public class MainMenu extends Activity {
static String status = "Hello Friends";
static TextView tv;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.mytext);
tv.setText(status);
MyOtherClass myclass = new MyOtherClass();
myclass.connect();
}
In other class:
// Other class
public class MyOtherClass {
public MyOtherClass(){
}
public void connect(){
String strIP = Mtx.confRead("IPAddress");
String strPort = Mtx.confRead("Port");
String msg = "Connecting...";
MainMenu.tv.setText(msg);
}