android-activity

Android return object as a activity result

可紊 提交于 2020-08-18 02:32:39
问题 Is it possible to return object as a activity result from child activity to parent? Just something like: Intent resultIntent = new Intent(null); resultIntent.putExtra("STRING_GOES_HERE", myObject); setResult(resultIntent); finish(); If it is possible, how should I retrieve myObject in parent activity? I figured out, that to retrieve data I need to do something like this: protected void onActivityResult (int requestCode, int resultCode, Intent data) { if(requestCode == REQ_CODE_CHILD) {

Android return object as a activity result

大憨熊 提交于 2020-08-18 02:29:53
问题 Is it possible to return object as a activity result from child activity to parent? Just something like: Intent resultIntent = new Intent(null); resultIntent.putExtra("STRING_GOES_HERE", myObject); setResult(resultIntent); finish(); If it is possible, how should I retrieve myObject in parent activity? I figured out, that to retrieve data I need to do something like this: protected void onActivityResult (int requestCode, int resultCode, Intent data) { if(requestCode == REQ_CODE_CHILD) {

Android return object as a activity result

我们两清 提交于 2020-08-18 02:29:12
问题 Is it possible to return object as a activity result from child activity to parent? Just something like: Intent resultIntent = new Intent(null); resultIntent.putExtra("STRING_GOES_HERE", myObject); setResult(resultIntent); finish(); If it is possible, how should I retrieve myObject in parent activity? I figured out, that to retrieve data I need to do something like this: protected void onActivityResult (int requestCode, int resultCode, Intent data) { if(requestCode == REQ_CODE_CHILD) {

onActivityCreated is deprecated, how to properly use LifecycleObserver?

久未见 提交于 2020-08-04 06:01:47
问题 Google deprecate fragment’s onActivityCreated() on Android and recommend to use LifeCycleObserver: To get a callback specifically when a Fragment activity's * {@link Activity#onCreate(Bundle)} is called, register a * {@link androidx.lifecycle.LifecycleObserver} on the Activity's * {@link Lifecycle} in {@link #onAttach(Context)}, removing it when it receives the * {@link Lifecycle.State#CREATED} callback. So I try to make it in recommended way, but only state I can observe in Logcat is just

How to reference the current or main activity from another class

末鹿安然 提交于 2020-07-31 06:39:29
问题 I often find myself needing to access methods that require referencing some activity. For example, to use getWindowManager , I need to access some Activity. But often my code for using these methods is in some other class that has no reference to an activity. Up until now, I've either stored a reference to the main activity or passed the context of some activity to the class. Is there some better way to do this? 回答1: If you already have a valid context, just use this: Activity activity =

Two cardview created, when trying to update the cardview

旧巷老猫 提交于 2020-07-23 06:35:29
问题 I'm trying to design a page where address are stored in recycler view -> cardview. When the user clicks the add address button from the Activity A the user is navigated to the add address page in Activity B. Here the user can input customer name, address line 1 and address line two. Similarly, When the user clicks the edit address button from the Activity A**(data in activity A is passed to activity B)** the user is navigated to the edit address page in Activity B. Here the user can input

Two cardview created, when trying to update the cardview

青春壹個敷衍的年華 提交于 2020-07-23 06:33:43
问题 I'm trying to design a page where address are stored in recycler view -> cardview. When the user clicks the add address button from the Activity A the user is navigated to the add address page in Activity B. Here the user can input customer name, address line 1 and address line two. Similarly, When the user clicks the edit address button from the Activity A**(data in activity A is passed to activity B)** the user is navigated to the edit address page in Activity B. Here the user can input

How to display a View in Full Size on screen in Xamarin Android?

不问归期 提交于 2020-07-22 18:07:39
问题 I am unable to set the View Size matching the Display Size , below is the code, it is a Transparent View TestView testView; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); testView = new TestView(this); SetContentView(testView); } The Default Height of the View when the app runs is height=1206 but the Display Height is 1280 , i have used the following methods to set the View Size match the Screen Size, but none works Does not work protected

Room database + recyclerview, how to pass data to another activity and then retrieve information from database based on passed data

余生颓废 提交于 2020-07-22 10:53:06
问题 I'm trying to get Company id (&& Company name) in first activity, pass it into the second activity and there I'd like to retrieve all data from database based on that id (&& name), but the app crashes, below is the code. can someone provide me a working code snippet. Any kind of help will be appreciated. AdapterCompany public class AdapterCompany extends RecyclerView.Adapter<AdapterCompany.AdapterCompanyHolder> { private List<EntityCompany> entityCompanies = new ArrayList<>(); private

How to Open Any Website in Android Application in Android Studio

為{幸葍}努か 提交于 2020-07-09 07:53:49
问题 I just started a new appliction using android studio .. but i need to open a web page in my application i tried using web view but it doesnt worked out... when i open my app it crashes down <WebView android:id="@+id/web_view" android:layout_width="fill_parent" android:layout_height="fill_parent" /> and i included in java class file private WebView wb; @Override protected void onCreate(Bundle savedInstanceState) { wb=(WebView)findViewById(R.id.web_view); WebSettings webSettings=wb.getSettings(