Android :: Why Passing Objects To Intents Are Not Straight Forward?

Oct 29, 2010

Why is that the object has to be serialized or be Parcelable in order to be passed to an Intent ?

Android :: Why passing objects to intents are not straight forward?


Android :: Passing An ArrayList Of Objects

Nov 12, 2010

Is there a way to pass an Array List of objects between activities? The myObject implements Parcelable and I'm able to successfully pass the objects around individually, but that means I need to have an exact amount of "myObjects" coded. I want this to dynamically grow/shrink by what the user does with the app. I have seen some posts on the web about doing:

Activity A
ArrayList<myObject> myObjArray = new ArrayList<myObject>();

Then when passing this into the intent I would use:
intent.putParcelableArrayListExtra("myObjArray", myObjArray);

Activity B
ArrayList<myObject> myObjArray = new ArrayList<myObject>();
Bundle extras = getIntent().getExtras(); myObjArray = extras.getParcelableArray("myObjArray");

However, the myObjArray always gets filled with "null". How can I achieve this?

View 3 Replies View Related

Android :: Passing Values With Intents

Nov 17, 2010

I have searched and searched and I just can't get this code to work. I have a main.xml layout and a setting.xml. I have some values I would like the Settings.class to change in my main apps class.Three string to be exact. I have tried this simple test code in my main app class.

settings.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), Settings.class);
startActivityForResult(intent, 0);}});

//Then a function
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent){
super.onActivityResult(requestCode, resultCode, intent);
Bundle extras = intent.getExtras();
String value = extras.getString("myKey");
if(value!=null){
Log.d("hmmm",value);}}}

In my settings.class I have the following
returnHome.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.putExtra("myKey", "YEAH");
setResult(RESULT_OK, intent);
finish();}});

Back in main app class it is not getting logged. Like I said I have three string in the main class that I want settings class to change and send back.

View 2 Replies View Related

Android :: Pass Complex Objects With Help Of Intents?

Nov 18, 2010

I am trying to extend the "android.content.Intent" class by adding a private attribute of a custom class. My goal is to send complex objects from the main Activity to a background Service.
The extension itself is not a problem, the class gets compiled without any errors and the project runs. The only problem is that the BroadcastReceiver does not receive the modified Intent and the "onReceive" method gets never called.
It there any way to pass complex objects with the help of Intents?

View 1 Replies View Related

Android :: Straight Forward Broadcast Receiver To Open / Read File

Apr 16, 2009

I would like my app to pop up in the list of options for opening certain file types in the various file manager, email, and web browser apps. I'm having trouble figuring out how to begin. I haven't found any examples of this sort of thing yet. Don't I need to know what kind of action the other app is trying to invoke on a selected file? How can I possibly know that? Or should I simply assume that all file manager, email, and browser apps will always use ACTION_VIEW or perhaps ACTION_EDIT when trying to send a file to another app? Must I simply assume this and hope I'm right? There are so many possible apps to try to get this to work with, how do I make it receive a "open-file" command from any arbitrary app? Is the code below correct so far? I have the following in the manifest:

<receiver android:enabled="true" android:exported="true" android:label="Some Label, where does this show up?" android:name=".MyBroadcastReceiver" >
<intent-filter> <action android:name="android.intent.action.ACTION_EDIT" />
</intent-filter> <intent-filter> <action android:name="android.intent.action.ACTION_VIEW" /> </intent-filter> </receiver>

I don't see how to specify a file-type or file extension filter in the receiver. How do I do this? Likewise I have the following in the receiver:

public class MyBroadcastReceiver extends BroadcastReceiver {
@Override public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.ACTION_EDIT")
|| intent.getAction().equals("android.intent.action.ACTION_VIEW")) {
Uri uri = intent.getData(); String uriStr = intent.getDataString();
} } }

View 10 Replies View Related

Android :: Transfer List Of Specific Objects Across Intents?

Apr 18, 2010

I wish to send a list of type <MyFriend> from one activity to another. I dont find a bundle.put...... for such an requirement in the api's. Is there a way somebody could suggest through which I could transfer different kinds of data.

View 2 Replies View Related

Android :: Passing Intents From Service To New Launch From Main Activity

Mar 30, 2009

How do you pass an intent from a service to a new activity launched from a main activity? There's a passextra( intent src ); but I don't think thats what I am looking for?

activity main > start service( intent wuteverserviceintent );
activity main > start activity( intent newactivityintent );

View 2 Replies View Related

Android :: How To Send Custom Data Objects With Intents Phone?

Jul 30, 2010

Intents in Android are an elegant way to pass messages between uncoupled components, but what if you want to send extra data with the Intent? I know you can add various value types, and objects that implement Parcelable, as extras, but this doesn't really cater for sending user defined types locally (i.e. not over a remote interface). Any ideas?

View 3 Replies View Related

Android :: Failed Binder Transaction When Passing Byte - From Camera - Between Intents

Feb 16, 2010

I have a problem with an app that lets the user take a picture. I've posted it on some forums already, but nobody seems to recognize the problem. Hopefully someone here knows a solution :)

I've put the code of taking a picture in a seperate activity. Then I call the camera intent from my main activity using activityForResult. In the camera intent, I use putExtra to return the camera image (as a byte[] without doing anything to it). But when the program transitions back from the camera intent to the parent intent that called it I get a Failed Binder Transaction error in the logcat because the byte[] is too big. But I don't understand this, because the image is not even taken using the maximum resolution :S

The code of my camera intent is:

CODE:......................

View 6 Replies View Related

Android :: Android Bundles Passing Pointer Or Copies Of Objects

Jul 5, 2010

If I attach an object to a bundle and store the bundle in an intent and start another activity, does that activity work on a copy of the original object or does it use the same object but just passes along a pointer?

View 1 Replies View Related

Android :: Pass Objects Around Activities Using A HashMap Of WeakReferences To Objects?

Oct 26, 2010

The FAQ mentions a method of passing objects around activities. (It is not clear to me): "A HashMap of WeakReferences to Objects. You can also use a HashMap of WeakReferences to Objects with Long keys. When an activity wants to pass an object to another activity, it simply puts the object in the map and sends the key (which is a unique Long based on a counter or time stamp) to the recipient activity via intent extras. The recipient activity retrieves the object using this key.".................

View 7 Replies View Related

Android :: How To Filter Objects To Display Onscreen Objects On Map?

Jun 15, 2010

I have an application that have a Google map on Google Android 1.5 since we have been working on the application for a long time, we are not in stage of upgrading to the newest framework, so we are using 1.5. Now, I have map locations that are dynamically generated and drawn on the map at run-time to visualize some streams, Up to this point the application is working fine, Now my problem is that I am trying to filter the objects ( addresses) to visualize only the on-screen ones. I do NOT want to visualize the addresses that are off-screen. The way I am trying to do this is to check the screen-coordinates of each object (address) before visualizing it, then it the coordinates (x,y) more than (0,0) and less than (320, 460). I should visualize it. I am trying to use this approach, but it is not working for some reasons, I have tried many posts but could not understand why, there must be something missing somewhere that I am not aware of.

View 11 Replies View Related

Android :: Possible Bug With Intents / Pending Intents

Nov 7, 2009

I have some code that is creating and removing alarms, and which works great in Android 1.5 and 1.6 but breaks on the Android 2.0 AVD.The code that's giving this exception is: Code...

View 3 Replies View Related

Android :: Following Straight Line (via Path)?

Nov 4, 2010

I'm working on a game which will use projectiles. So I've made a Projectile class and a new instance is created when the user touches the screen:

@Override
public boolean onTouch(View v, MotionEvent e){
float touch_x = e.getX();
float touch_y = e.getY();
new Projectile(touch_x, touch_y);

And the Projectile class:
public class Projectile{
float target_x;
float target_y;
Path line;

public Projectile(float x, float y)
target_x = x;
target_y = y;
line = new Path();
line.moveTo(MyGame.mPlayerXPos, MyGame.mPlayerYPos);
line.lineTo(target_x, target_y);

So this makes a Path with 2 points, the player's position and and touch coords. My question is - How can you access points on this line? For example, if I wanted to get the x,y coords of the Projectile at the half point of the line, or the point the Projectile would be at after 100 ticks (moving at a speed of X pixels/tick)? I also need the Projectile to continue moving after it reaches the final point. Do I need to use line.addPath(line) to keep extending the Path?

I managed to get the Projectiles moving in a straight line, but they're going in strange directions. I had to fudge some code up:
private void moveProjectiles(){
ListIterator<Projectile> it = Registry.proj.listIterator();
while ( it.hasNext() ){
Projectile p = it.next();
p.TimeAlive++;

double dist = p.TimeAlive * p.Speed;
float dx = (float) (Math.cos(p.Angle) * dist);
float dy = (float) (Math.sin(p.Angle) * dist);
p.xPos += dx;
p.yPos += -dy;

The Angle must be the problem. I'm using this method, which works perfectly:
private double getDegreesFromTouchEvent(float x, float y){
double delta_x = x - mCanvasWidth/2;
double delta_y = mCanvasHeight/2 - y;
double radians = Math.atan2(delta_y, delta_x);
return Math.toDegrees(radians);
However, it returns 0-180 for touches above the center of the screen, and 0 to -180 for touches below.

View 3 Replies View Related

Android :: Widget To Get Straight To 'network Operators'

Mar 16, 2010

Sometimes my phone loses signal, and then doesn't pick it up as quickly as I'd like.Normally,I go into settings, to 'wireless controls, mobile networks, network operators' to force it to pick up my network. I'm looking for either an app/widget/shortcut to take me straight from my homescreen to 'network operators' without having to click through the various settings menus, or advice on building the link myself.

View 4 Replies View Related

Android :: Send Contacts Straight To Voicemail

Feb 6, 2009

I know there is a way to send contacts straight to voicemail but is there an app that can block calls or can someone please make one.

View 10 Replies View Related

HTC Hero : Dumped TouchFlo And Gone To Straight Android

Aug 9, 2009

I got fed up with slow responses, graphical fripperies that get in the way and occasional incompatibilities and have now dumped the HTC user interfaces as I wasn't using their widgets anyway, that's all you really lose. Even HTC's home app has an annoying "overshoot" for effect when scrolling from one screen to the next, which just gets in the way. Looks nice at first but gets annoying after a week or so. Am now using stock Android and the phone's a lot quicker.

View 11 Replies View Related

Android : Way To Create A Shortcut To Go Straight To Call Log?

Apr 17, 2010

is there a way to create a shortcut to go straight to the call log? Its rediculous that we cant have a button to go straight to the last dialled contacts.. Since mobiles existed, when you hit the phone button you go into Cal Log...

View 4 Replies View Related

Android :: Any Application So That Outgoing Call Go Straight To Voicemail?

May 15, 2010

I thought I had seen some application where you can call someone and have it go straight to their voicemail. I've been looking around and haven't been able to find it. Does anyone know if such an app exists.

View 4 Replies View Related

Android :: Uploading Images Straight To Forums From Camera Possible?

Dec 9, 2008

Is there an application in the Market that will make it possible to upload direct from the camera to enable images to be inserted into forums. Either direct into the forum post, or via a hosting site like imageshack.

View 11 Replies View Related

Android :: Using Touch Screen To Draw A Straight Line

Apr 13, 2009

Want to draw a line when I touch screen at two points. I can see OnTouch been invoked but after than everything breaks looks, the application crashes

I am using drawLine in Canvas.

CODE:......................

View 5 Replies View Related

Android :: TranslateAnimation Doesn't Animate Straight (X-only) But Also In Y-direction (diagonal) / Fix It?

Oct 26, 2010


I have a TranslateAnimation that shall animate a LinearLayout (isScrollContainer) to the left and to the right along the x-axis. The animation to the left works and the animation is straight - means that the view is animated horizontally only.

But the animation left to right doesn't work: instead of just moving the view from left to right along the x-axis, the view gets animated into the screen from diagonal lower-right corner. But for the Y parameters I pass fixed identical values.

Here is a flv movie that shows the animation and issue I described: http://tinyurl.com/24n4eac

Code as follows...

View 2 Replies View Related

HTC Hero :: Emails Does Not Always Come Through Straight Way

Oct 28, 2009

i have 3 accounts set up on the phone, blueyonder(virgin media) hotmail and gmail. I use my blueyonder account for my job and it is important that emails reach me in a timely manner, i have come from a blackberry so no probs there. The porblem i am having is the dont always come through straight away, i have the phone set to check server every 5 mins, yesterday evening at 18.00 i received 9 mails all at once which had been sent from 14.00 onwards in the afternoon. I have also have had it when emails have come through a day late. Does anyone get the same problems, is this a phone problem or a virgin media problem, i suppose it could be a connection problem but i have wifi at my home and this was on from when i got home.

View 4 Replies View Related

Android :: Passing ArrayList Across Activities

Apr 7, 2009

I have an ArrayList<MyList> aList in an activity. I would like to send this data to another activty. Such that,
ArrayList<MyList> aList;
Intent intent = new Intent(); intent.setClass(mainactivity.this, newActivity.class); intent.putExtra("MyList", aList ); startActivity(intent);

On the receiving activity,
Intent i = getIntent(); newList = (ArrayList<MyList>) i.getSerializableExtra("MyList");
But this gets me no where. ERROR! My intention is to share this List between activities.

View 4 Replies View Related

Android :: Passing Values From One Activity To Another

Feb 11, 2010

I have an app which makes use of several layout-views. Every layout - view also got a class for it, which extend the Activity class. One class for example retrieves some database values whilst offering a search form to the user. Afterwards the user can select one of those values and he gets presented with another screen which gives similar options as the one selected. Anyways, I'd like for the first Activity to be able to send an array with data (Strings for example) to the second one. Right now I show an activity by using:

Intent i = new Intent(this, activitysName.class); startActivity(i);

I have no idea whilst using this construction how I can "initialize" the new object with the String array I want to pass to it. So how should this be achieved ? Should I be using something else instead of an Intent-Activity combination ?

View 5 Replies View Related

Android :: Passing Intent Value To Another Class

Oct 14, 2010

I have four groups in a listview each with four url's I want to load in a webView. When the user select a url to goto I set a value like so;

if (position == 0) webb = webb +2;
{
Intent intent = new Intent(this, official.class);
startActivity(intent);
}

I then carryout the intent to move to the webView class where I have given each URL a value like so;

if (webb == 2) mWebView.loadUrl("http://yahoo.com");
if (webb == 3) mWebView.loadUrl("http://www.bbc.co.uk");

But the screen stays blank, if I state the value inside the official.class it works. How can I get this value to pass to another class based on the selection the user makes from the listview.

View 3 Replies View Related

Android :: Passing Intent Value From One Class To Another

Oct 16, 2010

I have been trying to get "getExtra" to work but without success, I have a listview with 4 choices which launch a webpage within a webView class, when the user selects the option lets say option 3 I want to pass the value of 3 to the webView class so that it will load the correct webpage, at the moment I get no errors, but the app force closes when I select the option, could this be due to having to announce this in the manifest? can somebody help with where I am going wrong. This is my intent

public void onListItemClick(ListView l, View v, int position, long id) {
if (position == 0) {
Intent intent = new Intent(this, official.class);
intent.putExtra("weburl", 3);
startActivity(intent);}
This is the official class:
public class official extends Activity {
int number = getIntent().getIntExtra("weburl", 0);
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
mWebView.goBack();
return true;
} return super.onKeyDown(keyCode, event);
} WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.browser1);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
if (number == 2) mWebView.loadUrl("http://bcafc.livewwware.co.uk");
if (number == 3) mWebView.loadUrl("http://www.bbc.co.uk");
mWebView.setWebViewClient(new HelloWebViewClient());

View 1 Replies View Related

Android :: Passing Parameter Value To Web Service

Nov 4, 2010

How to pass parameter value to web service in Android?

View 2 Replies View Related

Android :: Passing Bitmap To Another Activity

Jun 7, 2010

I have a Bitmap image and i want to forward the bitmap to another activity. I have two activities Activity A and Activity B. This is how I started the Activity B
startActivityForResult(new Intent(Activity A.this, Activity B.class), 120);
in activity B
private void forwardImage(Bitmap bit) {
Intent i = new Intent(MMS.this, Compose.class);
i.putExtra("MMS", bit);
setResult(RESULT_OK, i);
finish(); }

This is not forwarding to Activity A but if I put a String to the intent it'll forward. This is how I listen to result in Activity A

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
// super.onActivityResult(requestCode, resultCode, data);
switch (resultCode)
case RESULT_OK: Intent intent = getIntent();
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("MMS");
mmsImage.setImageBitmap(bitmap);
default: break;
} }

How can I pass a bitmap.

View 3 Replies View Related

Android :: Passing Variable From One Class To Another

Nov 15, 2010

I am working to set a countdown timer. I have successfully (borrowed) a number picker (spinner) and set up the dialog box for the user to set the time. This is in a class called timepickactivity and the variables are hour and mins (R.id.hour and R.id.mins). I want to call the set values (R.id.hour and R.id.mins) from the dialog (timepickeractivity) to the actual countdown class (countdown) but I can't figure out how to get the values.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved