Need help about Intent

by gganesh » Tue, 24 Feb 2009 13:38:26 GMT


Sponsored Links
 hi friends,
i have two classes Screen1 and Screen2 both extends activity
i have to pass data from the Screen1 to Screen 2

i wrote in onCreate method of Screen1 class


 t=(EditText)findViewById(R.id.ed1);
 b=(Button)findViewById(R.id.but1);
         b.setOnClickListener(new Button.OnClickListener()
         {
                public void onClick(View v)
                {
                        Intent i= new Intent(v.getContext(),Screen2.class);
                        i.putExtra("myval",t.toString());
                        startActivity(i);
                }

My doubt is ,how to receive myval data in Screen2 class ,what is the
code i have to add in AndroidManifest.xml file
--~--~---------~--~----~------------~-------~--~----~



Need help about Intent

by dillirao malipeddi » Tue, 24 Feb 2009 13:46:11 GMT


 you have to
use

Bundle your_extras = getIntent.getExtras();

String val = your_extras.getExtras("myval");








-- 
Dilli Rao. M
ARIJASOFT
+91 - 9703073540

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Need help about Intent

by gganesh » Tue, 24 Feb 2009 16:43:02 GMT


 but the code   " your_extras.getExtras(myval) ; "
didn't work ,i suppose there is no such method in Bundle class
i tried as show below
       Bundle your_extras = this.getIntent().getExtras();
        String val = (String) your_extras.get("myval");
 but the "val" doesn't gives me the required data
Any suggestions ?
Thanks





On Feb 24, 10:46am, dillirao malipeddi <dillir...@arijasoft.com>



--~--~---------~--~----~------------~-------~--~----~



Need help about Intent

by dillirao malipeddi » Tue, 24 Feb 2009 17:03:00 GMT


 in your first Activity

        Intent my_intent = new Intent(FirstScreen.this.getApplication(),
SecondScreen.class);

        my_intent.putExtra("Value_String", "HaiHow R U");

        startActivity(intent);


in your Second Activity
in onCreate

Bundle extras = getIntent().getExtras();

String fromFirstActivity= extras.getString("Value_String");

you can use fromFirstActivity as from previous activity value


imp:

 the value pasesed in putExtras()   // Value_String

use the same for get the value in second Activity









-- 
Dilli Rao. M
ARIJASOFT
+91 - 9703073540

--~--~---------~--~----~------------~-------~--~----~



Need help about Intent

by dillirao malipeddi » Tue, 24 Feb 2009 17:07:17 GMT


 n your first Activity

b.setOnClickListener(new Button.OnClickListener()


load_SecondActivity()
{

Intent my_intent = new Intent(FirstScreen.this.getApplication(),
SecondScreen.class);

my_intent.putExtra("Value_String", "HaiHow R U");

startActivity(my_intent);
}

in your Second Activity
in onCreate

Bundle extras = getIntent().getExtras();

String fromFirstActivity= extras.getString("Value_String");

you can use fromFirstActivity as from previous activity value


On Tue, Feb 24, 2009 at 2:32 PM, dillirao malipeddi <dillir...@arijasoft.com




--
Dilli Rao. M
ARIJASOFT
+91 - 9703073540

--~--~---------~--~----~------------~-------~--~----~



Need help about Intent

by gganesh » Tue, 24 Feb 2009 17:18:54 GMT


 sorry, i have made a minor mistake ,the code given by me works
perfectly
and the "val" is displayed as excepted  .






--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. MediaPlayer seeking back

I've been using androids MediaPlayer to stream from an http url and
have a question about seeking.  Currently, our urls expire after they
have been used once or a certain time out has expired to dissuade
scraping content.  Now, this obviously makes progressive streaming
past the buffer impossible with the exact same url as you need to open
a new http connection with the same mangled key, which we
intentionally don't allow.

However, MediaPlayer seems to do this when seeking before the current
position (i.e. seeking from 1:00 in the audio to 0:30).  As the file
has already been downloaded up to the current position I'm confused as
to why MediaPlayer is still trying to initate a new http connection in
this case?  The only thing I can think of is that MediaPlayer is
getting rid of audio its already played up to the current position,
and hence needs to restart the connection if you try to seek back on
the stream.  Is this correct, or is there something else going on?

Thanks,
Ed

--~--~---------~--~----~------------~-------~--~----~

2. Should onSaveInstanceState call super?

Hello,

At the beginning of my onSaveInstanceState I was calling
super.onSaveInstanceState(outState) and everything was working fine.
But now I wrote an instrumentation test case which basically does:

                Activity activity = getActivity();
                getInstrumentation().callActivityOnStart(activity);
                getInstrumentation().callActivityOnResume(activity);
                Bundle outState = new Bundle();
                getInstrumentation().callActivityOnSaveInstanceState(activity, 
outState);

and I'm getting this error: "Only the original thread that created a
view hierarchy can touch its views." (stack trace at the bottom). So
I'm wondering, what am I doing wrong here? the test or the app?

Thanks.
-- 
J. Pablo Fernndez <pup...@pupeno.com> (http://pupeno.com)

PS: The stack trace:

Error in testLoadingAndSavingState:
android.view.ViewRoot$CalledFromWrongThreadException: Only the
original thread that created a view hierarchy can touch its views.
        at android.view.ViewRoot.checkThread(ViewRoot.java:1849)
        at android.view.ViewRoot.invalidateChild(ViewRoot.java:468)
        at android.view.ViewRoot.invalidateChildInParent(ViewRoot.java:481)
        at android.view.ViewGroup.invalidateChild(ViewGroup.java:2250)
        at android.view.View.invalidate(View.java:4095)
        at android.widget.TextView.invalidateCursor(TextView.java:2767)
        at android.widget.TextView.access$1300(TextView.java:151)
        at android.widget.TextView$ChangeWatcher.spanChange(TextView.java:4278)
        at android.widget.TextView$ChangeWatcher.onSpanAdded(TextView.java:4304)
        at 
android.text.SpannableStringInternal.sendSpanAdded(SpannableStringInternal.java:312)
        at 
android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:136)
        at android.text.SpannableString.setSpan(SpannableString.java:46)
        at 
android.text.SpannableStringInternal.<init>(SpannableStringInternal.java:50)
        at android.text.SpannableString.<init>(SpannableString.java:30)
        at android.widget.TextView.onSaveInstanceState(TextView.java:2015)
        at android.view.View.dispatchSaveInstanceState(View.java:4944)
        at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1052)
        at android.view.ViewGroup.dispatchSaveInstanceState(ViewGroup.java:1052)
        at android.view.View.saveHierarchyState(View.java:4927)
        at 
com.android.internal.policy.impl.PhoneWindow.saveHierarchyState(PhoneWindow.java:1314)
        at android.app.Activity.onSaveInstanceState(Activity.java:1055)
        at blah.blah.Blah.onSaveInstanceState(TodoEdit.java:110)
        at android.app.Activity.performSaveInstanceState(Activity.java:999)
        at 
android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1255)
        at 
blah.blah.BlahTest.testLoadingAndSavingState(TodoEditIntegrationTest.java:37)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:136)
        at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:126)
        at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:155)
        at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:142)
        at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:313)
        at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1508)

--~--~---------~--~----~------------~-------~--~----~

3. Android or G1 is eating too much battery power?

4. Question about following the activitycreator script

5. Differing HTTP packages?

6. Background Repeat in relativeLayout

7. Using a layout defined in xml with a custom class