android-bundle

Getting data from clicked notification in android

瘦欲@ 提交于 2019-12-04 01:57:48
问题 Hey guys I need help on how to get the data from my pending intent which is set using a broadcast receiver. What I want to happen is to get the data of an id when the notification is clicked which will be needed for my activity. this is how I make the extras public class AlertReceiver extends BroadcastReceiver { private int id; // Called when a broadcast is made targeting this class @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); String

Sending Intent from BroadcastReceiver class to currently running activity

僤鯓⒐⒋嵵緔 提交于 2019-12-03 13:32:37
I have a class which extends BroadcastReceiver . On receiving a SMS, I would like to pass information to my main activity class to display the text in a box (Append, if already text is present). public class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent i = new Intent(context, MainActivity.class); i.putExtra("updatedString","Hello"); context.startActivity(i); } } MainActivity.java public class MainActivity extends Activity{ private TextView results; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

Does retrieving a parcelable object through bundle always create new copy?

≯℡__Kan透↙ 提交于 2019-12-03 12:21:54
I'm passing a parcelable object to a fragment by adding into a bundle while creating the fragment. In onc instance modification to this parcelled object reflects modification in original object and in another case it is not. I'm a little baffled by this behaviour. Till now I have assumed retrieving a parcelled objects through a bundle always create new object[no sure whether it's shallow copy or deep copy]. Someone please clarify parcelable behaviour. I was struggling with a similar issue. At the first glance it seems that we always obtain a new deep copy from the parcelled objects. Moreover,

.getExtras()' on a null object reference

天涯浪子 提交于 2019-12-02 10:40:29
I am trying to pass a few values between my activities to make a game work. However, the new activity after passing the information always returns null when I try to .getExtras(). Any thoughts? Code: package name.zerosum; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.RadioButton; import android.widget.Spinner; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import java.util.ArrayList; public class NewGameActivity

Getting data from clicked notification in android

元气小坏坏 提交于 2019-12-01 10:48:18
Hey guys I need help on how to get the data from my pending intent which is set using a broadcast receiver. What I want to happen is to get the data of an id when the notification is clicked which will be needed for my activity. this is how I make the extras public class AlertReceiver extends BroadcastReceiver { private int id; // Called when a broadcast is made targeting this class @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); String title = bundle.getString("title"); String time = bundle.getString("time"); id = bundle.getInt("id");

Size limitation on attached Parcelable?

喜夏-厌秋 提交于 2019-12-01 02:34:29
I want to know is there any size limitation on Parcelable that attached to an Intent ? I Read some docs about Intents , Bundles , Parcelable again and there was nothing about size limitation. But I read some answers , that say size of attached Parcelable is limited (for example, 1 MB). So are Parcelable s limited by size or it only depends to the device? Its explained on the docs here . The transaction buffer for each process is 1 mb. In my understanding the factors to be considered are: Individual size of transactions(maximum 1 mb) The number of transactions(the sum of size of all

Size limitation on attached Parcelable?

拟墨画扇 提交于 2019-11-30 22:06:51
问题 I want to know is there any size limitation on Parcelable that attached to an Intent ? I Read some docs about Intents , Bundles , Parcelable again and there was nothing about size limitation. But I read some answers, that say size of attached Parcelable is limited (for example, 1 MB). So are Parcelable s limited by size or it only depends to the device? 回答1: Its explained on the docs here. The transaction buffer for each process is 1 mb. In my understanding the factors to be considered are:

Android App Bundle build error: reserved file

雨燕双飞 提交于 2019-11-30 12:52:20
The new app publishing format, the Android App Bundle, is an improved way to package your app. The Android App Bundle lets you more easily deliver a great experience in a smaller app size, allowing for the huge variety of Android devices available today. You don’t need to refactor your code to start benefiting from a smaller app. I'm getting this error trying to build my app Android Bundle: File 'root/AndroidManifest.xml' uses reserved file or directory name 'AndroidManifest.xml'. APK generation works fine . This is my project file structure: And this is my AndroidManifest.xml, located under

Saving information from one fragment and dialog if the user navigates to another fragment

a 夏天 提交于 2019-11-29 16:25:07
I have a screen where the user presses a button to bring up a DialogFragment with an EditText . They enter their information, and press Ok . If they press the button again, I've made it so the EditText will display the information they had just put in, and everything works fine. However, if they enter the information, press Ok , and then use the options menu to go look at another screen/ fragment , the information will not be displayed in the EditText once they press the button again. How can I save the information even if the user navigates away from that screen for a moment? I think it would

FAILED BINDER TRANSACTION while passing Bitmap from one activity to another

匆匆过客 提交于 2019-11-29 08:45:14
I want to pass a image as a bitmap from one activity to another. And i want to know whether it is possible to do like that. Sending Activity Intent intent = new Intent(getApplicationContext(), BitmapActivity.class); Bundle b = new Bundle(); b.putParcelable("BITMAP", bitmap); intent.putExtras(b); startActivity(intent); Receiving Activity Bundle bb = this.getIntent().getExtras(); b = bb.getParcelable("BITMAP"); But i am getting !!! FAILED BINDER TRANSACTION !!! Error You can use a global class with a static bitmap object in it, something like this: public class Global { static Bitmap img; }