android-activity

Android make callback to an Activity from java class

爱⌒轻易说出口 提交于 2021-02-20 16:21:26
问题 How can i make a callback to an Activity form a Java Class? Example: public class TestClass{ String text = "Test"; public TestClass(Context context){ startActivity(new Intent(context, SomeActivity.class)); } private void sendToSomeActivity(){ //Call some method of SomeActivity and pas text as string } } When sendToSomeActivity() is called, i want to make a callback to the already started SomeActivity and pass some text to the Activity. In SomeActivity i want to use the text. Note: The

Android make callback to an Activity from java class

﹥>﹥吖頭↗ 提交于 2021-02-20 16:20:47
问题 How can i make a callback to an Activity form a Java Class? Example: public class TestClass{ String text = "Test"; public TestClass(Context context){ startActivity(new Intent(context, SomeActivity.class)); } private void sendToSomeActivity(){ //Call some method of SomeActivity and pas text as string } } When sendToSomeActivity() is called, i want to make a callback to the already started SomeActivity and pass some text to the Activity. In SomeActivity i want to use the text. Note: The

Upgrading to Jetpack Compose Alpha 12 causes errors on setContent

喜欢而已 提交于 2021-02-20 05:51:10
问题 I upgraded to Jetpack Compose 1.0.0-alpha12 and started to run into issues. Firstly, the setContent method I was using showed as deprecated. From the Alpha 12 release notes, I noticed that it said: ComponentActivity.setContent has moved to androidx.activity.compose.setContent in the androidx.activity:activity-compose module. (Icf416) So I removed my import androidx.compose.ui.platform.setContent and switched it to import androidx.activity.compose.setContent , which removed the deprecation.

Start new Activity outside the Activity context.

三世轮回 提交于 2021-02-19 01:39:11
问题 I tried to start an Activity and close other in my AsyncTask class ( onPostExecute() ). My code : Intent i = new Intent(parentActivity, ThunderHunter.class); c.startActivity(i); parentActivity.finish(); But it doesn't work, logcat shows : 08-01 18:01:27.640: E/AndroidRuntime(12398): android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? 08-01 18:01:27.640: E/AndroidRuntime(12398)

What does the android:configChanges=“screenSize” attribute do?

倖福魔咒の 提交于 2021-02-18 22:42:15
问题 I would like to know what the above mentioned attribute for an Activity in the AndroidManifest.xml does and why it (would be) needed? I have already read the Android documentation about this topic and the explaination is not quite clear to me. Id like to know an example case WHY I would have to set this attribute. 回答1: As you may have known every time a parameter of the phone changes the system rebuilds the whole Activity in order to load the new resources. On of these parameters is the

Cannot access 'androidx.activity.result.ActivityResultCaller'

一曲冷凌霜 提交于 2021-02-18 22:39:49
问题 I'm using androidx for quite a while and my Android project compiles fine, however recently my Android Studio throws tons of red for all Activity classes because of cannot access 'androidx.activity.result.ActivityResultCaller' which is a supertype of ... I use AppCompatActivity from androidx.appcompat:appcompat:1.1.0 My build.gradle has: ext.kotlin_version = '1.3.71' ... dependencies { classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.google.gms:google-services:4.3.3' And gradle

Cannot access 'androidx.activity.result.ActivityResultCaller'

巧了我就是萌 提交于 2021-02-18 22:39:44
问题 I'm using androidx for quite a while and my Android project compiles fine, however recently my Android Studio throws tons of red for all Activity classes because of cannot access 'androidx.activity.result.ActivityResultCaller' which is a supertype of ... I use AppCompatActivity from androidx.appcompat:appcompat:1.1.0 My build.gradle has: ext.kotlin_version = '1.3.71' ... dependencies { classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.google.gms:google-services:4.3.3' And gradle

singleTask launchMode in android not working

烈酒焚心 提交于 2021-02-18 11:27:31
问题 So, I have 4 activities Activity Activity1 , Activity2 , Activity3 and Activity4 . I start from Activity1 then on some event I start Activity2 then on some event on Activity2 I start Activity3 as a new task as public void onClick(View v) { Intent intent = new Intent(Activity2.this, Activity3.class); intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } Here Activity2 launchMode is decalared as singleTask. Then I navigate from Activity3 to

Android: Multiple Option Menus in one Activity

不想你离开。 提交于 2021-02-18 05:17:10
问题 I have an Activity containing a ViewFlipper and would like to show a different option menu for each view in that ViewFlipper . That is, the type of menu displayed when the menu button is pressed would depend on the type of the current view. However, onCreateOptionsMenu() is called only once (when showing the option menu for the first time), so creating the different menus can't be implemented there. How could I solve this? Any suggestions appreciated. 回答1: First read about

Android: How to swipe between activities (not fragments), master/detail best set-up

本小妞迷上赌 提交于 2021-02-17 21:00:14
问题 I'm working on an android app and I'm fairly new to all this, including mobile app development, so I have a few questions. Any help would be amazing! 1) Is it possible to swipe between entire activities (including action bar)? And I don't mean like viewPager swapping between fragments, I mean swapping the entire screen (like snapchat does on iOS). Is this possible at all? And if so, how can I do this? 2) What is the best way to implement a master/detail type layout? Like twitter for instance,