android-activity

Returning to previous activity in Xamarin Android

本秂侑毒 提交于 2021-02-11 15:02:59
问题 I have two activities: MainActivity and Activity2 : public class MainActivity : AppCompatActivity { DateTime time = DateTime.Now; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); var button = FindViewById<Button>(Resource.Id.button); button.Text = "Button created at " + time.ToString(); button.Click += (s, e) => { Intent intent = new Intent

Android get view of fragment in activity [duplicate]

徘徊边缘 提交于 2021-02-11 14:34:08
问题 This question already has answers here : findViewById in Fragment (35 answers) Closed 8 months ago . I have an activity, let's call it A , and it launches a fragment like so: remoteFragment = new RemoteFragment(); getSupportFragmentManager() .beginTransaction() .replace(R.id.frameLayout_remote_activity, remoteFragment) .commit(); my remoteFragment looks something like this: public Button okBtn; public RemoteFragment() { // Required empty public constructor } @Override public View onCreateView

How to make my Fragment make use of my Activity Data?

孤街醉人 提交于 2021-02-11 12:48:53
问题 I have an Activity hosting 3 Fragments, my activity contains some data that I want my first fragment to use. I tried invoking the following method so that the activity can communicate with the fragment: FirstFragment fragmentFirst = (FirstFragment) getSupportFragmentManager().findFragmentById(R.id.firstFragment); assert fragmentFirst != null; fragmentFirst.doSomething("some param"); For the activity class and: public void doSomething(String param) { // do something in fragment } For the

Data binding - XML not updating after onActivityResult

非 Y 不嫁゛ 提交于 2021-02-10 13:15:49
问题 Updating ObservableField inside onActivityResult(..) of activity but not reflecting that value to XML . If I call executePendingBindings() it will work. But the issue is, there are a lot of ObservableField and for every variable, I need to call executePendingBindings() . Anyone knows how to solve this issue ? 回答1: In ViewDataBinding.java file, there is one method for requesting rebind protected void requestRebind() { if (mContainingBinding != null) { mContainingBinding.requestRebind(); } else

Data binding - XML not updating after onActivityResult

回眸只為那壹抹淺笑 提交于 2021-02-10 13:10:38
问题 Updating ObservableField inside onActivityResult(..) of activity but not reflecting that value to XML . If I call executePendingBindings() it will work. But the issue is, there are a lot of ObservableField and for every variable, I need to call executePendingBindings() . Anyone knows how to solve this issue ? 回答1: In ViewDataBinding.java file, there is one method for requesting rebind protected void requestRebind() { if (mContainingBinding != null) { mContainingBinding.requestRebind(); } else

onContextMenuClosed not implemented in Fragment

别说谁变了你拦得住时间么 提交于 2021-02-10 09:46:10
问题 Strange, neither Fragment nor v4.Fragment implemented the "onContextMenuClosed". Other events are there, like onCreateContextMenu and onContextItemSelected. I need to clean up something when the context menu is dismissed, which can be activated by back button, tapping on the blank area on screen, or select one menu item in the context menu. How do I monitor the dismissal of a context menu in a fragment then? 回答1: The menu close event in a fragment will also trigger its parent activity's

How to get android:configChanges values from ActivityInfo class

天涯浪子 提交于 2021-02-10 06:19:21
问题 I would like to fetch activities info(Such as configchanges, resizemode, if Picture in Picture is supported) of all the packages present in the device. I am able to fetch the activities info using PackageManager with GET_ACTIVITIES flag. With that I can get configChanges value using ActivityInfo.configChanges . However the value returns a random int if there are multiple config values set in android:configChanges . For ex: if below values are set android:configChanges="uiMode

ActivityResultContracts.TakePicture()

戏子无情 提交于 2021-02-08 16:42:35
问题 In androidx.activity version 1.2.0-alpha05 API for TakePicture contract has been changed: The TakePicture contract now returns a boolean indicating success rather than a thumbnail Bitmap as this was very rarely supported by camera apps when writing the image to the provided Uri While in alpha04 callback received a Bitmap object, now only a Boolean object that describes success is received by the callback. So now the Uri Parameter of the launch method of the launcher must not be null, but must

ActivityResultContracts.TakePicture()

青春壹個敷衍的年華 提交于 2021-02-08 16:38:09
问题 In androidx.activity version 1.2.0-alpha05 API for TakePicture contract has been changed: The TakePicture contract now returns a boolean indicating success rather than a thumbnail Bitmap as this was very rarely supported by camera apps when writing the image to the provided Uri While in alpha04 callback received a Bitmap object, now only a Boolean object that describes success is received by the callback. So now the Uri Parameter of the launch method of the launcher must not be null, but must

onCreate vs. onResume/onRestart bevhaviour regarding member variables

时光总嘲笑我的痴心妄想 提交于 2021-02-08 13:17:32
问题 When I open an activity I know that I can initialize stuff in the onCreate function. But what is the behaviour on the OnResume and onRestart function? When are these functions called? Specifically: I initialize a local member variable in the onCreate function auiqring a reference to a global object. Now, when the user is interrupted, for example, by a call, the activity can be closed. Later, when the user comes back to my view, what is the status of the already initiliazed variable? Do I have