main-activity

Cannot find MainActivity.java in Android Studio [closed]

孤人 提交于 2021-01-27 14:44:25
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question I am currently writing an Android App using Android Studio 1.2. However, i cannot find MainActivity.java file in it. Hope someone can help me out. Thanks in advance. Regards, Al 回答1: Its not necessary that your file is named MainActivity.java. That is the

Issues with creating new Android MainActivity

左心房为你撑大大i 提交于 2020-01-25 03:39:28
问题 I'm new to Android programming and am attempting to create a new Main Activity for my app (taken from the Android tutorial website). My original Main Activity is called "MainActivity". The new activity I want to be my Main Activity is called "Homepage" and it should contain a button that produces "MainActivity" upon clicking. I'm unsure what or where I'm supposed to include information in the manifest regarding the new page "homepage", homepage.xml, and the button. Specific code would be

Preventing main activity from being launched if running already

走远了吗. 提交于 2019-12-22 05:58:26
问题 I have an application that is launched via an intent-filter action. The problem is that every time the event/ action occurs, Android displays a dialog asking to launch the app even if it is already started. I want the behavior to be as follows: User asked to launch the app if app is not open. Dialog does not display if app is running in the foreground. Is there a way to achieve both of these goals? I am targeting Android 4.0. edit Here is my intent filter: <intent-filter> <action android:name

android - Sending a broadcast to MainActivity and then showing a TextView

[亡魂溺海] 提交于 2019-12-18 07:22:27
问题 I want to unhide a TextView once a method is called in another View file. The TextView is in MainActivity. For this, I am planning to send a broadcast from the View file to MainActivity, but it didn't work. How would I achieve this? 回答1: Step 0 : Define an action : public static final String ACTION_SHOW_TEXT= "showText"; Step 1 : Create your Broadcast receiver in your MainActivity : BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent

How to set my Activity as main activity in android? [duplicate]

≯℡__Kan透↙ 提交于 2019-12-17 22:32:38
问题 This question already has answers here : Change application's starting activity (10 answers) Closed last year . I want to create own activity as main activity rather than using default MainActivity . How can I define that in android manifest? 回答1: In your manifest file , use the below code to declare an activity as a launcher activity: <activity android:name=".yourActivityName" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent

Accessing main activity in Broadcast Reciever without using intent

筅森魡賤 提交于 2019-12-12 05:13:20
问题 I am stuck in a problem. I have a broadcast receiver that calls the method of class takes in context and main activity reference in constructor. I dont know how to access main activity in broadcast receiver.Here is my code: public void onReceive(@NonNull Context context, @NonNull Intent intent) { if (context == null) { throw new IllegalArgumentException(); } ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm

How to pass context from MainActivity to another class in Android?

随声附和 提交于 2019-12-08 11:44:53
问题 I am experiencing an issue when trying to pass the context from the MainActivity class to another. Here is the ContextPasser Class. public class ContextPasser extends Application{ public Context context; public ContextPasser(){ context = getApplicationContext(); }} But if I use the context variable in the other class, like this: Line line = new Line(new ContextPasser().context); I am getting a null pointer exception. I want to get a solution which does not involve passing in a context

Preventing main activity from being launched if running already

十年热恋 提交于 2019-12-05 09:03:37
I have an application that is launched via an intent-filter action. The problem is that every time the event/ action occurs, Android displays a dialog asking to launch the app even if it is already started. I want the behavior to be as follows: User asked to launch the app if app is not open. Dialog does not display if app is running in the foreground. Is there a way to achieve both of these goals? I am targeting Android 4.0. edit Here is my intent filter: <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent

'TAG' has private access in 'android.support.v4.app.FragmentActivity'

a 夏天 提交于 2019-12-03 11:53:43
问题 Almost everything in my activity is working fine, except for wherever TAG is referenced. TAG gets a red line and says: 'TAG' has private access in 'android.support.v4.app.FragmentActivity' . MainActivity (without imports)- public class MainActivity extends AppCompatActivity { public static final String DATA_PATH = Environment .getExternalStorageDirectory().toString() + "/MainActivity"; public static final String lang = "eng"; protected Button _button; protected ImageView _image; protected

'TAG' has private access in 'android.support.v4.app.FragmentActivity'

安稳与你 提交于 2019-12-03 01:25:29
Almost everything in my activity is working fine, except for wherever TAG is referenced. TAG gets a red line and says: 'TAG' has private access in 'android.support.v4.app.FragmentActivity' . MainActivity (without imports)- public class MainActivity extends AppCompatActivity { public static final String DATA_PATH = Environment .getExternalStorageDirectory().toString() + "/MainActivity"; public static final String lang = "eng"; protected Button _button; protected ImageView _image; protected TextView _field; protected String _path; protected boolean _taken; @Override public void onCreate(Bundle