[Solved] I want to reduce the code in Android

Are all the buttons currently in the same class? Because if so, you can just make a method that does the work, and call it for each button, passing as method arguments any variables that change from button to button. If not, you can still make a method, but you’ll just have to make it … Read more

[Solved] StartActivityforResult brackets meaning [closed]

public void startActivityForResult (Intent intent, int requestCode) Added in API level 1 Same as calling startActivityForResult(Intent, int, Bundle) with no options. Parameters intent The intent to start. requestCode If >= 0, this code will be returned in onActivityResult() when the activity exits. Quoted from Android Developers. It’s like a reply for the calling method. 1 … Read more

[Solved] Navigating from an activity to a fragment [duplicate]

You can use from switching from Fragment to Activity-: Implement this code on BackPressed-: @Override public void onBackPressed() { super.onBackPressed(); YourFragment mapFragment = new YourFragment(); FragmentManager manager = getFragmentManager(); manager.beginTransaction().replace(R.id.landlord_apartment, mapFragment, mapFragment.getTag()).commit(); } While moving from Fragment to Activity-: startActivity(new Intent(getActivity,YourActivity.Class)); and while moving from activity to Fragment-: YourFragment mapFragment = new YourFragment(); FragmentManager manager … Read more

[Solved] How to do offline maps in android? [closed]

You have the option of using OpenStreet Map via osmdroid. osmdroid is a (almost) full/free replacement for Android’s MapView (v1 API) class. It also includes a modular tile provider system with support for numerous online and offline tile sources and overlay support with built-in overlays for plotting icons, tracking location, and drawing shapes. 4 solved … Read more

[Solved] how can parse this xml file? [closed]

try This try { InputStream mInputStream = getAssets().open(“XmlData.xml”); XmlPullParserFactory xmlFactoryObject = XmlPullParserFactory.newInstance(); XmlPullParser myparser = xmlFactoryObject.newPullParser(); myparser.setInput(mInputStream, null); int event = myparser.getEventType(); while (event != XmlPullParser.END_DOCUMENT) { String name=myparser.getName(); switch (event){ case XmlPullParser.START_TAG: break; case XmlPullParser.END_TAG: if(name.equals(“page”)){ Log.e(“TAG”,””+ myparser.getAttributeValue(null,”id”)); Log.e(“Page content “,””+ myparser.getAttributeValue(null,”text”)); } break; } event = myparser.next(); } } catch (Exception e) { … Read more

[Solved] Asking the user for a URL to receive a JSON

Create a constructor in your async Task private class JSONTask extends AsyncTask<String, String, String> { String url; public JSONTask(String url){ this.url=url; } use the url string in place of params[0] And wherever you call your async task do it like this new JSONTask(textView.getText()).execute() This should solve it. Else you can directly use the do in … Read more

[Solved] My android application is getting stopped

Go to the your Manifest file and do this in the activity where you want to show the Toolbar <activity android:name=”.YourActivity” android:theme=”@style/AppTheme.NoActionBar”><!– ADD THIS LINE –> Then in styles.xml add the following: <style name=”AppTheme.NoActionBar”> <item name=”windowActionBar”>false</item> <item name=”windowNoTitle”>true</item> </style> solved My android application is getting stopped

[Solved] Choosing language at startup

If I understand you correctly you wish to display that activity only when the user runs the app for the first time. Well, here’s what you can do: 1) Get a handle to a SharedPreference. This is to store if the user has already selected the language or not. SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); 2) Create … Read more

[Solved] How to make a text change you from one screen to another [closed]

I suppose you are referring to changing from one screen (activity) to another by typing something and not by clicking a button. If that is the case use TextWatcher and on change check for your string (or command) and move to next screen. Something like. textView.addTextChangedListener(new TextWatcher(){ public void afterTextChanged(Editable s) {} public void beforeTextChanged(CharSequence … Read more

[Solved] how to integrate firebase performance monitoring in Android [closed]

1. Go to project level build.gradle and add buildscript { repositories { jcenter() mavenLocal() google() } dependencies { //Your gradle version example classpath ‘com.android.tools.build:gradle:3.1.3’ //play services plugin example classpath ‘com.google.gms:google-services:3.2.0’ classpath ‘com.google.firebase:firebase-plugins:1.1.5’ // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } 2. App level … Read more

[Solved] Removing html tags in from a string in android [closed]

I use this function this way, public String removeTags(String in) { int index=0; int index2=0; while(index!=-1) { index = in.indexOf(“<“); index2 = in.indexOf(“>”, index); if(index!=-1 && index2!=-1) { in = in.substring(0, index).concat(in.substring(index2+1, in.length())); } } return in; } I tried to do that with the function replaceAll() using regular experssion, but never had a good … Read more