How do I create a transparent Activity on Android?

Add the following style in your res/values/styles.xml file (if you don’t have one, create it.) Here’s a complete file: <?xml version=”1.0″ encoding=”utf-8″?> <resources> <style name=”Theme.Transparent” parent=”android:Theme”> <item name=”android:windowIsTranslucent”>true</item> <item name=”android:windowBackground”>@android:color/transparent</item> <item name=”android:windowContentOverlay”>@null</item> <item name=”android:windowNoTitle”>true</item> <item name=”android:windowIsFloating”>true</item> <item name=”android:backgroundDimEnabled”>false</item> </style> </resources> (The value @color/transparent is the color value #00000000 which I put in the res/values/color.xml file. … Read more

How to manage startActivityForResult on Android

From your FirstActivity, call the SecondActivity using the startActivityForResult() method. For example: int LAUNCH_SECOND_ACTIVITY = 1 Intent i = new Intent(this, SecondActivity.class); startActivityForResult(i, LAUNCH_SECOND_ACTIVITY); In your SecondActivity, set the data which you want to return back to FirstActivity. If you don’t want to return back, don’t set any. For example: In SecondActivity if you want … Read more

Activity restart on rotation Android

Using the Application Class Depending on what you’re doing in your initialization you could consider creating a new class that extends Application and moving your initialization code into an overridden onCreate method within that class. public class MyApplicationClass extends Application { @Override public void onCreate() { super.onCreate(); // TODO Put your application initialization code here. … Read more

How do I pass data between Activities in Android application?

In your current Activity, create a new Intent: String value=”Hello world”; Intent i = new Intent(CurrentActivity.this, NewActivity.class); i.putExtra(“key”,value); startActivity(i); Then in the new Activity, retrieve those values: Bundle extras = getIntent().getExtras(); if (extras != null) { String value = extras.getString(“key”); //The key argument here must match that used in the other activity } Use this … Read more

How can I save an activity state using the save instance state?

You need to override onSaveInstanceState(Bundle savedInstanceState) and write the application state values you want to change to the Bundle parameter like this: @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); // Save UI state changes to the savedInstanceState. // This bundle will be passed to onCreate if the process is // killed and restarted. savedInstanceState.putBoolean(“MyBoolean”, true); … Read more

How to stop EditText from gaining focus when an activity starts in Android?

Adding the tags android:focusableInTouchMode=”true” and android:focusable=”true” to the parent layout (e.g. LinearLayout or ConstraintLayout) like in the following example, will fix the problem. <!– Dummy item to prevent AutoCompleteTextView from receiving focus –> <LinearLayout android:focusable=”true” android:focusableInTouchMode=”true” android:layout_width=”0px” android:layout_height=”0px”/> <!– :nextFocusUp and :nextFocusLeft have been set to the id of this component to prevent the dummy … Read more

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