[Solved] How to fetch data from a website in android app after entering his personal details during registration?

You can write a RESTful web service on your server which takes the arguments like (age,income,etc) and store these arguments to a new variable then use those variable when connecting the government’s website. After that you can use your government’s APIs if there are any, if not: you can write a web scraper for that … Read more

[Solved] Calculate the difference between two dates in hours:minutes:seconds?

Try this function:- //1 minute = 60 seconds //1 hour = 60 x 60 = 3600 //1 day = 3600 x 24 = 86400 public void printDifference(Date startDate, Date endDate){ //milliseconds long different = endDate.getTime() – startDate.getTime(); System.out.println(“startDate : ” + startDate); System.out.println(“endDate : “+ endDate); System.out.println(“different : ” + different); long secondsInMilli = 1000; … Read more

[Solved] How to get day of week name from selected date month and year in Android?

First convert your Date in to specific Date format using SimpleDateFormat Use SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“EEEE”); to get Day name in week WHERE EEEE -> Day name in week SAMPLE CODE SimpleDateFormat inFormat = new SimpleDateFormat(“dd-MM-yyyy”); try { Date myDate = inFormat.parse(date+”-“+month+”-“+year); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“EEEE”); String dayName=simpleDateFormat.format(myDate); } catch (ParseException e) { … Read more

[Solved] Need Help Regarding Percentage Calculator Project [closed]

you can do it like this EditText input = (EditText) findViewById(R.id.ip); Button button = (Button) findViewById(R.id.calcbutton); TextView textView = findViewById(R.id.tv15); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int num = Integer.parseInt(input.getText().toString()); // for 0.15% float fifteen_percent = (float) ((num * 0.15) + num); textView.setText(String.valueOf(fifteen_percent)); } }); You can do the same for remaining … Read more

[Solved] I need to create a Android activity that’s protected with a pin code [closed]

When Ok is pressed after the pin is entered you need to verify if the entered pin is the same as the saved pin, if yes you can open the activity you want to. You need to have an edittext to collect the pin. <EditText android:id=”@+id/passwordedittext” android:layout_width=”200dp” android:layout_height=”wrap_content” android:inputType=”textPassword”> <requestFocus /> An ok button is … Read more

[Solved] Bundle.putInt() , how does it work?

1) You can share int with other activity like this : String YOUR_KEY = “id”; Intent intent = new Intent(getApplicationContext(), DisplayContact.class); intent.putExtra(YOUR_KEY, id); startActivity(intent); or Bundle dataBundle = new Bundle(); dataBundle.putInt(YOUR_KEY, id); intent.putExtras(dataBundle); 2) And get int in your activity like that : int defaultValue = 0; int id = getIntent().getIntExtra(YOUR_KEY, defaultValue); or Bundle extras … Read more

[Solved] Android – Fatal Exception AsynckTask #1

You cannot show a Toast from a background thread. Please remove the Toast from your print() method. If you are using this Toast for debugging purposes, consider switching to the Log class to log things to LogCat, or using breakpoints in your IDE. 1 solved Android – Fatal Exception AsynckTask #1

[Solved] How to manipulate LIst

From the other code, I think you are working on Java but this line bit confusing me, var Bd=beaconDevices; As if you are on Java then you have to use your code like, List<BeaconDevice> B=beaconDevices; for(i=0;i<B.Size();i++) { BeaconDevice beaconDevice = B.get(i); } 1 solved How to manipulate LIst

[Solved] How to store an image path in the shared preferences in android?

All you have to do is, convert your image to it’s Base64 string representation: Bitmap realImage = BitmapFactory.decodeStream(stream); ByteArrayOutputStream baos = new ByteArrayOutputStream(); realImage.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] b = baos.toByteArray(); String encodedImage = Base64.encodeToString(b, Base64.DEFAULT); textEncode.setText(encodedImage); SharedPreferences shre = PreferenceManager.getDefaultSharedPreferences(this); Editor edit=shre.edit(); edit.putString(“image_data”,encodedImage); edit.commit(); and then, when retrieving, convert it back into bitmap: SharedPreferences shre … Read more

[Solved] Why Do We Extend Application Class In Android [closed]

Android apps run properly even without extending it. Android apps can run properly without extending it. They can run properly without extending Activity. You extend Application when it does something useful for you. Can anyone explain this scenario as why exactly do we extend it. It is used for per-process initialization that should always happen, … Read more

[Solved] How can i use less than or equal to for a string? [closed]

user_bal is a String data type and hence <= is not preferred. If you sure the value of this variable will be numbers (integer as variable lim is of type int, used for compare) , then try this String user_bal = (String) dataSnapshot.child(“balance”).getValue(); int userBalance = Integer.parseInt(user_bal); if (userBalance <= lim){ // do something Toast.makeText(PostActivity.this, … Read more