android

Can help me to delete data from firebase and recyclerView?

痴心易碎 提交于 2021-02-17 07:14:09
问题 I did recyclerView retrieve data from firebase real-time database, and created button for delete item from recycelerView and from database I have 2 questions 1- after i add new item in recyclerView and then try delete it not delete directly , just when add item and run code again then i can delete it public class WorkerRecyclerViewAdapter extends RecyclerView.Adapter<WorkerRecyclerViewAdapter.ViewHolder> { private Context context; private ArrayList<Worker> workersList; private

Unable to parse JSON object using Volley

浪尽此生 提交于 2021-02-17 07:11:32
问题 JSON file: JSON FILE URL i am looping through the "biller" Array to fetch all the object's where "billerCategory": is "Electricity". I am trying to get "paramName" value. But i am only getting 3 paramName values. Response: Code: try { JSONArray biller = response.getJSONArray("biller"); Log.d(TAG, biller.toString()); // Loop through biller Array and find billerID for (int i = 0; i < biller.length(); i++) { JSONObject billerObj = (JSONObject) biller.get(i); String category = billerObj.getString

error: incompatible types: boolean cannot be converted to int

烈酒焚心 提交于 2021-02-17 07:09:20
问题 I'm getting the error: incompatible types: boolean cannot be converted to int error while compiling the android app in Android Studio. The problem is in only one method. private static int get_wx_inx(String str) { boolean equalsIgnoreCase = str.equalsIgnoreCase("木"); int equalsIgnoreCase2 = str.equalsIgnoreCase("火"); if (str.equalsIgnoreCase("土")) { equalsIgnoreCase2 = true; } if (str.equalsIgnoreCase("金")) { equalsIgnoreCase2 = 3; } return str.equalsIgnoreCase("水") ? 4 : equalsIgnoreCase2; }

How to delete multiple child nodes from different parents nodes where a particular value exists [closed]

隐身守侯 提交于 2021-02-17 07:06:24
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 days ago . Improve this question Hello guys I'm developing an app and using firebase realtime as my database. I have a node called Users which stores patients and doctors. I also have a different node called Mypatient which stores patient and doctors details whom they're enrolled to. what I want to achieve is if

Why do I get null in data parmeter of onActivityResult

孤者浪人 提交于 2021-02-17 07:05:45
问题 I use the following code to take picture from the android camera, after taking the pic onActivityResult is called with data parameter equals NULL. Code - public void getpic(View v){ Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); }

Convert UTC String to UTC Date [Android - Java] [duplicate]

僤鯓⒐⒋嵵緔 提交于 2021-02-17 07:04:14
问题 This question already has answers here : want current date and time in “dd/MM/yyyy HH:mm:ss.SS” format (10 answers) Getting the current time millis from device and converting it into a new date with different timezone [duplicate] (2 answers) SimpleDateFormat with timezone displaying dates in my timezone, how do I fix this? [duplicate] (2 answers) Closed 5 months ago . I want to convert UTC time to Date. It should return Date as Expected result is : 2020-09-01T08:44:25.654Z output is -> "Tue

How can I check if a value e.g. name exists in a collection within any of documents in Cloud Firestore?

妖精的绣舞 提交于 2021-02-17 06:44:05
问题 I want to check if a value e.g. (name: ‘John’) exists in the collection of any document in my Cloud Firestore, because if it does I do not want to create a new document with that name (in this case ‘John’). How can I check if the name exists? 回答1: Assuming you have in Firestore a collection called "users", to check if a user with the name of "John" already exists, please use the following lines of code: FirebaseFirestore rootRef = FirebaseFirestore.getInstance(); CollectionReference usersRef

Can't use setBackgroundResource() when using Thread.sleep on click

99封情书 提交于 2021-02-17 06:37:05
问题 I can successfully change color by using: TextView1.setOnClickListener{ TextView1.setBackgroundResource(R.color.red); } But if I use TextView1.setOnClickListener{ TextView1.setBackgroundResource(R.color.red); Thread.sleep(1_000) TextView1.setBackgroundResource(R.color.white); } color doesn't change at all. Why is that? 回答1: This is due to the fact that calling Thread.sleep() just causes your thread to hang, in this particular example, it causes the GUI (graphical user interface) thread to

How to make media player stop when pressing device back button from a fragment back to activity

半腔热情 提交于 2021-02-17 06:21:25
问题 My problem is that media player keeps playing when i press device back button. How to completely destroy the fragment and the media player and everything in it when pressing device back button so that it is not visible on the screen? I'm new to programming so all advice and comments on how to improve the code are welcome. Thank you Activity: import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentManager; import android.os.Bundle; import android.view.View; import