How to pass an object from one activity to another on Android

One option could be letting your custom class implement the Serializable interface and then you can pass object instances in the intent extra using the putExtra(Serializable..) variant of the Intent#putExtra() method. Actual Code: In Your Custom Model/Object Class: public class YourClass implements Serializable { At other class where using the Custom Model/Class: //To pass: intent.putExtra(“KEY_NAME”, … Read more

android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData()

If your targetSdkVersion >= 24, then we have to use FileProvider class to give access to the particular file or folder to make them accessible for other apps. We create our own class inheriting FileProvider in order to make sure our FileProvider doesn’t conflict with FileProviders declared in imported dependencies as described here. Steps to … Read more

How can I connect to Android with ADB over TCP? [closed]

Manual Process From your device, if it is rooted According to a post on xda-developers, you can enable ADB over Wi-Fi from the device with the commands: su setprop service.adb.tcp.port 5555 stop adbd start adbd And you can disable it and return ADB to listening on USB with setprop service.adb.tcp.port -1 stop adbd start adbd … Read more

How to send an object from one Android Activity to another using Intents?

If you’re just passing objects around then Parcelable was designed for this. It requires a little more effort to use than using Java’s native serialization, but it’s way faster (and I mean way, WAY faster). From the docs, a simple example for how to implement is: // simple class that just has one member property … Read more

“Conversion to Dalvik format failed with error 1” on external JAR

Go to Project » Properties » Java Build Path » Libraries and remove all except the “Android X.Y” (in my case Android 1.5). click OK. Go to Project » Clean » Clean projects selected below » select your project and click OK. That should work. It is also possible that you have a JAR file … Read more

How to hide the title bar for an Activity in XML with existing custom theme

Do this in your onCreate() method. //Remove title bar this.requestWindowFeature(Window.FEATURE_NO_TITLE); //Remove notification bar this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //set content view AFTER ABOVE sequence (to avoid crash) this.setContentView(R.layout.your_layout_name_here); this refers to the Activity.

Converting pixels to dp

Java code: // Converts 14 dip into its equivalent px float dip = 14f; Resources r = getResources(); float px = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, dip, r.getDisplayMetrics() ); Kotlin code: val dip = 14f val r: Resources = resources val px = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, dip, r.displayMetrics ) Kotlin extension: val Number.toPx get() = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, this.toFloat(), Resources.getSystem().displayMetrics)

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)