Re: [android-developers] startActivityForResult() from service

2012-10-12 Thread Anthony Prieur
Create a custom facade for the built in SL4A RPC server as explained here: 
https://code.google.com/p/android-python27/wiki/TutorialHowToCreateCustomRpcFacade

And POST the result back to Java from you Python script 
e.g. droid.myResult(xxx)


Le jeudi 11 octobre 2012 14:27:17 UTC+2, Archana a écrit :
>
> Hi,
>
> I have to execute a Python script from my service. I need to wait till the 
> script has finished execution and returns a result. Hence am using it. 
>
> On Thursday, October 11, 2012 3:20:41 PM UTC+3, Mark Murphy (a Commons 
> Guy) wrote:
>>
>> On Thu, Oct 11, 2012 at 8:13 AM, Archana  wrote: 
>> > Hi, I have defined a service. 
>> > 
>> > I need to call startActivityForResult(intent,REQUEST_CODE) from this. 
>>
>> That is not supported. IMHO, it does not even make any sense. Why do 
>> you think that you "need" to do this? 
>>
>> -- 
>> Mark Murphy (a Commons Guy) 
>> http://commonsware.com | http://github.com/commonsguy 
>> http://commonsware.com/blog | http://twitter.com/commonsguy 
>>
>> _The Busy Coder's Guide to Android Development_ Version 4.2 Available! 
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] startActivityForResult() from service

2012-10-11 Thread Archana
Hi,

I have to execute a Python script from my service. I need to wait till the 
script has finished execution and returns a result. Hence am using it. 

On Thursday, October 11, 2012 3:20:41 PM UTC+3, Mark Murphy (a Commons Guy) 
wrote:
>
> On Thu, Oct 11, 2012 at 8:13 AM, Archana 
> > 
> wrote: 
> > Hi, I have defined a service. 
> > 
> > I need to call startActivityForResult(intent,REQUEST_CODE) from this. 
>
> That is not supported. IMHO, it does not even make any sense. Why do 
> you think that you "need" to do this? 
>
> -- 
> Mark Murphy (a Commons Guy) 
> http://commonsware.com | http://github.com/commonsguy 
> http://commonsware.com/blog | http://twitter.com/commonsguy 
>
> _The Busy Coder's Guide to Android Development_ Version 4.2 Available! 
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] startActivityForResult() from service

2012-10-11 Thread Mark Murphy
On Thu, Oct 11, 2012 at 8:13 AM, Archana  wrote:
> Hi, I have defined a service.
>
> I need to call startActivityForResult(intent,REQUEST_CODE) from this.

That is not supported. IMHO, it does not even make any sense. Why do
you think that you "need" to do this?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.2 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult() from service

2012-10-11 Thread Archana
Hi, I have defined a service.

I need to call startActivityForResult(intent,REQUEST_CODE) from this.  I 
saw 
http://stackoverflow.com/questions/3448485/startactivityforresult-from-a-service

But can someone explain me? Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] startActivityForResult using android.support.v4.app.FragmentActivity

2012-09-06 Thread Amy Chen
Hi,

Would anyone know if I'm doing something wrong? 
I'm trying to call my library's activity (similar to listactivity) from a 
fragment in the main project, and return to the main project upon selecting 
an item from the library's activity.
All the code runs normally up to selecting the item in the library's 
activity. onItemSelected runs, but the onActivityResult(int requestCode, 
int resultCode, Intent data) from the main project doens't get called, and 
the main project seems to have disappeared once the library's activity 
finished.
Here is the simplified code:

>From main project (android.support.v4.app.Fragment)
public void onClick(View v) {
switch(v.getId()) {
case R.id.btnFind:
   startActivityForResult(newIntent, 
com.kitten.library.intent.kittenlabs_db_request_code);
   break;
}
 }

@Override
public void onActivityResult(int requestCode, int resultCode, Intent 
data) {
super.onActivityResult(requestCode, resultCode, data);

/* code to handle result
*/
}

>From library (android.app.Activity)
public void onItemClick(AdapterView parent, View v, int position, 
long id) {
//move cursor to selected item
c.moveToPosition(position);

//get row id
int rowID = c.getInt(c.getColumnIndex("_id"));

//construct result uri
Uri outURI = ContentUris.withAppendedId(this.db_uri, rowID);
Intent outData = new Intent();
outData.setData(outURI);
setResult(Activity.RESULT_OK, outData);
finish();
}

I've tried to put onActivityResult in the FragmentActivity class as well, 
but it does not get called either. Once "finish();" is called from the 
library activity, the main project is not visible (I see the Android home).

Thank you very much in advance,
Amy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] startActivityforResult does not return any result on Samsung Galaxy

2012-06-14 Thread Tanja Zimmermann
The following Code works for HTC but not on Samsung Galaxy:

final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(getTempFile(this)) );
startActivityForResult(intent, TAKE_PHOTO_CODE);

private File getTempFile(Context context){
File path = new File( Environment.getExternalStorageDirectory(),
context.getPackageName() );
if(!path.exists()){
path.mkdir();
}
return new File(path, "image.tmp");
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch(requestCode){
case TAKE_PHOTO_CODE:

final File file = getTempFile(this);
captureBmp = Media.getBitmap(getContentResolver(),
Uri.fromFile(file) );
int width = captureBmp.getWidth();
int height = captureBmp.getHeight();
int newWidth = width - ((width*40)/100);
int newHeight = height - ((height*40)/100);
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
resizedBitmap = Bitmap.createBitmap(captureBmp, 0, 0,
width, height, matrix, true);
bmd = new BitmapDrawable(resizedBitmap);
ImageView iv = (ImageView) findViewById (R.id.iv_foto_beleg);
 iv.setImageDrawable(bmd);
SharedPreferences sharedPreferences = getPreferences(MODE_PRIVA
long id = sharedPreferences.getLong("id", 0);
break;
 }
 }
After press saving the camera activity does not turn back to the
activity, which launched the it. The picture is not on sdcard. Is
there anybody can help? Thanks in advance.


Greetings


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult problem

2012-01-19 Thread vani reddy
Hi friends,

In my application I am switching betweeen 4 activities

ActivityA , ActivityB,ActivityC, ActivityD

while returning from actvityD i am setting
Intent in = new Intent();
in.putIntegerArrayListExtra("items", sel_supp);
setResult(RESULT_OK, in);
finish();

-- 
Regards,
Vani Reddy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] startActivityForResult

2011-10-27 Thread Kostya Vasilyev
As an extra in the intent you use with setResult.

--
Kostya Vasilyev
28.10.2011 1:41 пользователь "bob"  написал:

> If you are writing the called Activity in startActivityForResult, how
> do you return a String?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] startActivityForResult

2011-10-27 Thread bob
If you are writing the called Activity in startActivityForResult, how
do you return a String?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult does not return control to calling Activity

2011-06-05 Thread Anirvan
i have a tab layout. in one of the Activity's corresponding to a tab,
i use "startActivityForResult" to launch another activity to do
something. Once the tasks in the new activity are done, i invoke the
"finish()" method to return to the tab Activity which launched it.

strangely enough, when the new activity is finished, instead of
showing the tab activity which launched it, the entire app simply
exits. in the tab activity class i've overriden the "onActivityResult"
method, and have a log statement right at the start. This log
statement does not get printed.

so the gist of the problem is that when i launch an activity for
result, and then finish it, the control does not return back to the
activity which launched the other one - instead the app exits.

is there some elementary mistake that i'm making here?
thanks for your time.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] startActivityForResult

2011-05-18 Thread Giorgio Vespucci
In the upper right corner of API page there is a scrollbox you can use to
filter the minimum API level you want to see.
Hope this helps. :)
 Il giorno 19/mag/2011 05:44, "kypriakos"  ha scritto:

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] startActivityForResult

2011-05-18 Thread kypriakos

Hi all,

I am writing apps for some old phones (Android 1.6). I can call
startActivity(intent) without issues but the
startActivityForResult(intent, int) fails on compile? Was this method
introduced after 1.6? How can one see what's been deprecated across
versions?

Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult weirdness

2011-03-28 Thread Kevin
I'm writing an app and would like to redirect the user from the main
activity to enter a passcode. I've been able to run the passcode
activity from my settings/preferences activity no problem:
onActivityResult() gets called and everything works fine. From the
main activity (the one set as MAIN in AndroidManifest.xml), though, it
won't call onActivityResult(). I logged everything very closely and
the passcode activity is doing the same thing in both cases
(setResult() followed by finish()).

I noticed the RedirectEnter activity in the API demos, which is the
one set as MAIN, does not actually do the redirect either, the
redirect is in RedirectMain which is called only when you push the Go
button.

Is there some rule that says the MAIN activity cannot redirect?
Currently I'm formulating how to reorganize my app such that the
program doesn't ask for a passcode on the main screen, but that's
really not the most elegant solution.

I could post code but I've tried so many variations that I'm not sure
which one is best to post. I've tried delaying the call to the
passcode activity to later in the startup sequence (various points
from onCreate() through onAttachedToWindow()) to no avail.
onActivityResult() doesn't get called.

Thanks,

--Kevin

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] startActivityForResult for Contact picker under tab

2010-10-29 Thread TreKing
On Mon, Oct 25, 2010 at 10:33 PM, poj  wrote:

>  Is it possible to start contact intent under tab activity?
>

No.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] startActivityForResult for Contact picker under tab

2010-10-28 Thread poj
Dear All,

I have main activity that create three tabs like this

MainAct extends TabActivity{
...
onCreate(){
TabHost thost =getTabHost();
TabHost.TabSpec tspec;


Intent CIntent = new Intent().setClass(this, ClassB.class);
tspec = thost.newTabSpec("contact").setIndicator("Contact",
getResources().getDrawable(R.drawable.contact))
  .setContent(CIntent);
thost.addTab(tspec);
thost.addTab(tspec);
}
}

and ClassB will start contact intent like this

ClassB extends Activity{
...
protected void onResume() {
super.onResume();
startActivityForResult(new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI)
, 1000);
}
...
}

but contact intent start outside tab e.g. no tab on top of it. Is it
possible to start contact intent under tab activity?

Regards,
poj

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] startActivityForResult error

2010-05-27 Thread MiSs LilY flower
i don't know actually
sorry
may i need to read more about Java Oriented

2010/5/27 Tommy 

> Have you added the activity to the manifest file? What errors are you
> getting?
>
> -Original Message-
> From: android-developers@googlegroups.com
> [mailto:android-develop...@googlegroups.com] On Behalf Of andrew
> Sent: Wednesday, May 26, 2010 5:49 PM
> To: Android Developers
> Subject: [android-developers] startActivityForResult error
>
> Hi,
>
> I can't launch a new activity with startActivityForResult /
> startActivity method.
> Below is the code. Can anyone give my any tips and guidelines? thanks!
>
> /**/
> public class Sandbox extends Activity {
>
>private Button mHHW;
>private static final int ACTIVITY_CREATE = 0;
>
>/** Called when the activity is first created. */
>@Override
>public void onCreate(Bundle savedInstanceState) {
>super.onCreate(savedInstanceState);
>setContentView(R.layout.main);
>
>
>mHHW = (Button) findViewById(R.id.about_hhw);
>
>mHHW.setOnClickListener(new View.OnClickListener(){
>public void onClick(View v){
>createNote();
>}
>});
>}
>
>private void createNote() {
>Intent i = new Intent(this, PageTwo.class);
>startActivity(i);
>//startActivityForResult(i,ACTIVITY_CREATE);
>}
> }
>
> /**/
>
> public class PageTwo extends Activity {
>
>private Button mGoBack;
>
>@Override
>protected void onCreate(Bundle savedInstanceState) {
>// TODO Auto-generated method stub
>super.onCreate(savedInstanceState);
>setContentView(R.layout.page_two);
>
>/*
>mGoBack = (Button) findViewById(R.id.go_back);
>
>mGoBack.setOnClickListener(new View.OnClickListener(){
>public void onClick(View v){
>finish();
>}
>});
>*/
>
>}
>
> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] startActivityForResult error

2010-05-26 Thread Carmen Delessio
If my manifest looks like this:
 







I would create the intent like this (Bundle not required):
Bundle b = new Bundle();
b = new Bundle();
Intent i = new Intent();
b.putString("Some data","data for this
activity");
i = new Intent(".PageTwo");
i.putExtras(b);
startActivityForResult(i, ACTIVITY_CREATE);

Somewhere in your PageTwo Activity, I would expect to see:

setResult(RESULT_OK, i);  // where I is an
intent containing a bundle of data.  of just setResult(RESULT_OK) or
setResult(RESULT_CANCEL)
finish();

Somewhere in the calling activity, I would expect to see:
protected void  onActivityResult  (int requestCode, int resultCode, Intent
data){
if (requestCode==PICK_PHOTO){
if (resultCode == RESULT_OK) {


On Wed, May 26, 2010 at 5:48 PM, andrew  wrote:

> Hi,
>
> I can't launch a new activity with startActivityForResult /
> startActivity method.
> Below is the code. Can anyone give my any tips and guidelines? thanks!
>
> /**/
> public class Sandbox extends Activity {
>
>private Button mHHW;
>private static final int ACTIVITY_CREATE = 0;
>
>/** Called when the activity is first created. */
>@Override
>public void onCreate(Bundle savedInstanceState) {
>super.onCreate(savedInstanceState);
>setContentView(R.layout.main);
>
>
>mHHW = (Button) findViewById(R.id.about_hhw);
>
>mHHW.setOnClickListener(new View.OnClickListener(){
>public void onClick(View v){
>createNote();
>}
>});
>}
>
>private void createNote() {
>Intent i = new Intent(this, PageTwo.class);
>startActivity(i);
>//startActivityForResult(i,ACTIVITY_CREATE);
>}
> }
>
> /**/
>
> public class PageTwo extends Activity {
>
>private Button mGoBack;
>
>@Override
>protected void onCreate(Bundle savedInstanceState) {
>// TODO Auto-generated method stub
>super.onCreate(savedInstanceState);
>setContentView(R.layout.page_two);
>
>/*
>mGoBack = (Button) findViewById(R.id.go_back);
>
>mGoBack.setOnClickListener(new View.OnClickListener(){
>public void onClick(View v){
>finish();
>}
>});
>*/
>
>}
>
> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en




-- 
Carmen
http://www.twitter.com/CarmenDelessio
http://www.talkingandroid.com
http://www.facebook.com/BFFPhoto
http://www.twitter.com/DroidDrop

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

RE: [android-developers] startActivityForResult error

2010-05-26 Thread Tommy
Have you added the activity to the manifest file? What errors are you
getting?

-Original Message-
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of andrew
Sent: Wednesday, May 26, 2010 5:49 PM
To: Android Developers
Subject: [android-developers] startActivityForResult error

Hi,

I can't launch a new activity with startActivityForResult /
startActivity method.
Below is the code. Can anyone give my any tips and guidelines? thanks!

/**/
public class Sandbox extends Activity {

private Button mHHW;
private static final int ACTIVITY_CREATE = 0;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


mHHW = (Button) findViewById(R.id.about_hhw);

mHHW.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
createNote();
}
});
}

private void createNote() {
Intent i = new Intent(this, PageTwo.class);
startActivity(i);
//startActivityForResult(i,ACTIVITY_CREATE);
}
}

/**/

public class PageTwo extends Activity {

private Button mGoBack;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.page_two);

/*
mGoBack = (Button) findViewById(R.id.go_back);

mGoBack.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
finish();
}
});
*/

}

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult error

2010-05-26 Thread andrew
Hi,

I can't launch a new activity with startActivityForResult /
startActivity method.
Below is the code. Can anyone give my any tips and guidelines? thanks!

/**/
public class Sandbox extends Activity {

private Button mHHW;
private static final int ACTIVITY_CREATE = 0;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


mHHW = (Button) findViewById(R.id.about_hhw);

mHHW.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
createNote();
}
});
}

private void createNote() {
Intent i = new Intent(this, PageTwo.class);
startActivity(i);
//startActivityForResult(i,ACTIVITY_CREATE);
}
}

/**/

public class PageTwo extends Activity {

private Button mGoBack;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.page_two);

/*
mGoBack = (Button) findViewById(R.id.go_back);

mGoBack.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
finish();
}
});
*/

}

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] startActivityForResult returns result BEFORE activity starts.

2010-05-09 Thread TreKing
On Fri, May 7, 2010 at 12:51 PM, Nathan  wrote:

> Can anyone make any suggestions?


Check where your secondary activity is setting the result and double check
your logic there.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] startActivityForResult returns result BEFORE activity starts.

2010-05-07 Thread Nathan
OK, I'm stuck.

I call startActivityForResult. Based on everything I've read, this
should return a result after the activity calls finish().

But it doesn't.OnActivityResult() is called with the correct request
code IMMEDIATELY after startActivityForResult is called. Based on
debugging, this is happening before DownloadActivity.onCreate() is
called. If I add a default constructor to DownloadActivity, it also
happens before the constructor is called.

OnActivityResult is called.

Here are the relevant lines of code, both of them:

Intent intent = new Intent(this,DownloadActivity.class);
startActivityForResult(intent, DOWNLOAD_ACTIVITY_RESULT 
);

Since the ApiDemos example does work, I checked to see the manifest on
the SendResult Activity. I found it was very simple and changed mine
to match, but that didn't help.





This is the stack trace when OnActivityResult is called.

MyActivity.onActivityResult(int, int, Intent) line: 330
MyActivity(Activity).dispatchActivityResult(String, int, int, Intent)
line: 3828
ActivityThread.deliverResults(ActivityThread$ActivityRecord, List)
line: 3310
ActivityThread.handleSendResult(ActivityThread$ResultData) line: 3356
ActivityThread.access$2700(ActivityThread, ActivityThread$ResultData)
line: 119
ActivityThread$ResultData(ActivityThread$H).handleMessage(Message)
line: 1878
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4338
Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]

Can anyone make any suggestions? I know I haven't given you much to go
on, but I don't have any more. If I can't fix this, I can only
conclude that I can't use startActivityForResult, because it fails for
unknown reasons that I can't explain, even if it works just great for
all other developers.

Nathan

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] startActivityForResult and setResult problems

2010-03-31 Thread Mark Murphy
Lordsaibat wrote:
> ok I have two classes my main class calls a menu class when the user
> gets done with that they press the back button to go to the main
> class. on the main class I have onActivityResult setup but no matter
> what the data field is null all the time even though I setup the
> bundle and attached it to an Intent. Please look over my code and see
> what it going on.

I would not use onPause() for your setResult()/finish() call. First, I
think that is too late for the setResult() logic. Second, onPause() will
also be invoked at other times (e.g., when the user takes a phone call).

If you want to set the result when the use presses the BACK button, then
set the result when the user presses the BACK button, by implementing
onBackPressed() in newer versions of Android or onKeyDown() in older
versions of Android.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Consulting: http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult and setResult problems

2010-03-31 Thread Lordsaibat
ok I have two classes my main class calls a menu class when the user
gets done with that they press the back button to go to the main
class. on the main class I have onActivityResult setup but no matter
what the data field is null all the time even though I setup the
bundle and attached it to an Intent. Please look over my code and see
what it going on.

Main class

import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

public class caralarm extends Activity {



/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.menu, menu);
return(super.onCreateOptionsMenu(menu));
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {

if (item.getItemId()==R.id.close) {
Toast.makeText(this, "Trying to close app",
Toast.LENGTH_SHORT).show();
}

if (item.getItemId()==R.id.refresh) {
Toast.makeText(this, "Trying to refresh app",
Toast.LENGTH_SHORT).show();
}

if (item.getItemId()==R.id.settings) {
Toast.makeText(this, "Trying to open settings app",
Toast.LENGTH_SHORT).show();
launch_settings2();



}

return(super.onOptionsItemSelected(item));
}

 protected void onActivityResult(int requestCode, int resultCode,
Intent data){



if (data == null)
{
Log.d ("data", "data was null");
Number = Settings2.Number; //this works
Password = Settings2.Passwordtext;
Often = Settings2.NumMin;
return;

}

Bundle extras = data.getExtras();
String name = extras.getString("Alarm");
Toast.makeText(this, name, Toast.LENGTH_SHORT);

}

void launch_settings2(){
  Intent i = new Intent(this, Settings2.class);
  startActivityForResult(i, 0);

  }
}

Settings2 class
Import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.widget.EditText;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

public class Settings2 extends PreferenceActivity{
static String Number = "";
static String Passwordtext = "";
static String NumMin = "";

protected void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings2);
}

public static String getNumber (Context context){

return
PreferenceManager.getDefaultSharedPreferences(context).getString("AlarmNumber",
Number);
}

public static String getPassword (Context context){

return
PreferenceManager.getDefaultSharedPreferences(context).getString("Password",
Passwordtext);
}

public static String getNumMin (Context context){

return
PreferenceManager.getDefaultSharedPreferences(context).getString("Often",
NumMin);
}

@Override
protected void onPause(){
super.onPause();


//copy data
Number = getNumber(this);
Passwordtext = getPassword(this);
NumMin = getNumMin(this);

Bundle info = new Bundle();
info.putString("Alarm", Number );
info.putString("Password", Passwordtext);
info.putString("Often", NumMin);
Intent intent = new Intent();
intent.putExtras(info);


setResult(RESULT_OK, intent);
finish();



}
}



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.


Re: [android-developers] startActivityForResult

2010-02-27 Thread Mark Murphy
Pierre Henry wrote:
> Encoutered a tricky result using startActivityForResult from an
> Activity
> 
> In the called Activity , I set result like that:
> __
> setResult(RESULT_OK, getIntent().putExtra(getPackageName()+"values",
> values));
> __
> 
> When running the on ActivityResult, the extra has disappeared from
> intent in the method *onActivityResult*
> 
> In the api doc, it is telling that package name must be used , so I
> used it (see code upwards ).
> 
> So why is that ?

Create a fresh Intent (via new Intent()) and see if that helps.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult

2010-02-27 Thread Pierre Henry
Encoutered a tricky result using startActivityForResult from an
Activity

In the called Activity , I set result like that:
__
setResult(RESULT_OK, getIntent().putExtra(getPackageName()+"values",
values));
__

When running the on ActivityResult, the extra has disappeared from
intent in the method *onActivityResult*

In the api doc, it is telling that package name must be used , so I
used it (see code upwards ).

So why is that ?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult & singleTop.

2010-01-08 Thread Keean Schupke
I need to create an activity that can be "singleTop" so that multiple
intents get sent to the "onNewIntent" method without restarting the
activity.

I also need this activity to return a result. The basic behaviour is:


Activity "A" calls startActivityForResult on "B" one or more times
(providing updated information to "B"). When the user selects the
result from "B" it should return directly to "A".

I do not want the activity-transition animation to play each time "A"
updates "B" with new information.

How can I do this?


Cheers,
Keean.
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] StartActivityForResult

2010-01-06 Thread Mark Murphy

> I am using ListActivities to drill down into a hierarchy; artist,
> album and song. One activity per hierarchy. So, from the main
> activity  I start the ArtistActivity with the StartActivityForResult
> method and when the an artist is selected I call the
>
> protected void onListItemClick(ListView l, View v, int position, long
> id) {
>
> setResult(Activity.RESULT_OK, results);
> finish();
>
> }
>
> to return the results. Than the main activity receives results from
> the ArtistsActivity in the onActivityResult method and starts the next
> hierarchy’s activity, AlbumActivity, in the same way as the previous
> activity, on so on. It works fine except that when calling finish
> method the hierarchy activity is removed from the stack. So, it makes
> it impossible to backtrack to the previous hierarchy since it’s not
> there anymore. For example, I can’t backtrack from AlbumActivity to
> the ArtistsActivity since it has been removed from the stack.  My
> question is; is there any way to leave the hierarchy activities on the
> stack?

Instead of calling setResult()/finish() in a list item click,
startActivityForResult() the next level down in the hierarchy. Only the
leaf should call setResult()/finish() in a list item click. All branches
of the hierarchy should call setResult()/finish() in their
onActivityResult(), forwarding the leaf's result Intent along.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] StartActivityForResult

2010-01-06 Thread Business Talk
I am using ListActivities to drill down into a hierarchy; artist,
album and song. One activity per hierarchy. So, from the main
activity  I start the ArtistActivity with the StartActivityForResult
method and when the an artist is selected I call the

protected void onListItemClick(ListView l, View v, int position, long
id) {

setResult(Activity.RESULT_OK, results);
finish();

}

to return the results. Than the main activity receives results from
the ArtistsActivity in the onActivityResult method and starts the next
hierarchy’s activity, AlbumActivity, in the same way as the previous
activity, on so on. It works fine except that when calling finish
method the hierarchy activity is removed from the stack. So, it makes
it impossible to backtrack to the previous hierarchy since it’s not
there anymore. For example, I can’t backtrack from AlbumActivity to
the ArtistsActivity since it has been removed from the stack.  My
question is; is there any way to leave the hierarchy activities on the
stack?
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] startActivityForResult question

2009-12-31 Thread schwiz
Simple question, is it possible to implement startActivityForResult
and onActivityResult within a custom view class?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult and concurrent Activities

2009-12-13 Thread abnormative
I'm trying to understand the limits of startActivityForResult(), so I
can simplify my onActivityResult() logic.

An Activity can make back-to-back calls to startActivityForResult() in
a single method execution, seemingly kicking off multiple concurrent
sub-Activities. The startActivityForResult() method doesn't complain.
A sub-Activity will return a successful result in at least some cases
(I've played with this). Maybe that's only true for Activities that
don't have a GUI, such as TextToSpeech.Engine.ACTION_CHECK_TTS_DATA?

Are such sub-Activities really being executed concurrently? Or is
Android maybe queueing the requests for serial execution? Or...?

Some "best practices" questions:
1) If it is indeed possible to kick off concurrent sub-Activities, are
there situations where that's actually a good thing to do?
2) Is a non-GUI Activity sometimes a good implementation strategy, for
certain problems?

-Mark



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] startActivityForResult in onResume

2009-05-21 Thread skyman

Hello,

I have Action which can obtain data from two sources - from Intent's
extra and when there is no data it starts new anctivity and takes
results from it.

In the second case it tooks very long to do startActivityForResult.
It's faster even when i remove startActivityForResult from onResume
and run it from menu, but it's unacceptable for end-user.

This second Activity (started using startActivityForResult) has
android:theme="@android:style/Theme.Translucent" maybe it's the
problem.

There is also another strange thing - when I start that transcluent
activity from menu i can see "through" it (as I wanted), but when i
run it from startActivityForResult translucent space is black.

Regs,

Skyman
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] startActivityForResult/onActivityResult question

2009-05-21 Thread Tom Opgenorth

Hello all,
I'm new to Android development, and am a bit confused here. I'm
hoping someone can help me out.  Please forgive me as I cross post
this to android-developers - I tried on android-begginers last week
but got no response.


Anyway, I've got a very simple Activity with one EditText and one Button.
Lets call it MyActivity.  Now, when I click on the button on
MyActivity, I want to take a picture using the camera.  For the sake
of this e-mail, lets call the activity that gets spawned when I click
on the button CameraActivity.

Here is how I've setup my button:

   Button takePictureButton = (Button)
this.findViewById(R.id.receipt_take_picture_button);
   takePictureButton.setOnClickListener(new View.OnClickListener() {
   public void onClick(View v) {
   ContentValues values = new ContentValues();
   values.put(Media.TITLE, "IMAGE");
   values.put(Media.DESCRIPTION, "Image
Captured by Camera");
   Uri uri =
getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
   Intent i = new
Intent("android.media.action.IMAGE_CAPTURE");
   i.putExtra("output", uri);
   startActivityForResult(i,
ACTIVITY_TAKE_PICTURE_WITH_INTENT);
   }
   });

As I understand it, click the button will cause MyActivity to start up
CameraActivity, which is just the default camera application, to take
a picture.  Because I've used startActivityForResult, when
CameraActivity finishes, MyActivity should be notified via it's
onActivityResult.  Below is how I've coded it up:

I've defined my onActivityResult as follows:

   @Override
   protected void onActivityResult(int requestCode, int
resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   switch (requestCode) {
   case (ACTIVITY_TAKE_PICTURE_WITH_INTENT):
   Log.d(TAG, "WOW!");
   default:
   break;
   }
   }

So, what has me confused is this:  I would expect onActivityResult to
be called AFTER I take a picture, i.e. when I click on the picture
button.  Instead, it seems to get called immediately:  I click on the
takeAPictureButton, the camera activity starts up at about the same
time the code in onActivityResult gets fired.  Am I missing something
here?

TIA
-- 
http://www.opgenorth.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] startActivityForResult on tab

2009-04-06 Thread zeeshan

Hi Experts,

i need to start startActivityForResult on a tab click,

here is my activity senario:

Activity A  calling startActivityForResult -> B (tab activity)
startActivityForResult -> C onResult -> A
 
-> D onResult -> A



tabHost.addTab(tabHost.newTabSpec("Search")
.setIndicator("",getResources().getDrawable
(R.drawable.search_icon))
.setContent(new Intent(this, MyClass.class)));

how can i call the above MyClass as startActivityForResult ?

also can i call any function on tab click?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] startActivityForResult problems

2009-03-11 Thread Geos

Hello All

I've use startActivityForResult as it described in many examples but
it return 0 result code after start new Activity.

In main Activity I use such code for sub activity invocation

Intent iShowVideo = new Intent(EventHandling.this, 
ShowVideo.class);
startActivityForResult(iShowVideo, 
this.REQUEST_CODE_SHOW_VIDEO);

And such code for getting results.

@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
// TODO Auto-generated method stub
//super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE_SHOW_VIDEO){
if(resultCode == RESULT_CANCELED){
Toast toast = Toast.makeText(this, 
"onActivityResultCancel: " +
String.valueOf(resultCode), Toast.LENGTH_LONG);
toast.show();
}else{
Toast toast = Toast.makeText(this, 
"onActivityResult: " +
String.valueOf(resultCode), Toast.LENGTH_LONG);
toast.show();
}
}
}

Here is a part code from ShowVideo activity
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

setContentView(R.layout.showvideo);
//showDialog(DIALOG_YES_NO_MESSAGE);

Button button = (Button)findViewById(R.id.btnOK);
button.setOnClickListener(mOkListener);
button = (Button)findViewById(R.id.btnCancel);
button.setOnClickListener(mCancelListener);

//setResult(RESULT_OK, (new Intent()).setAction("Test!"));
}

private OnClickListener mOkListener = new OnClickListener()
{
public void onClick(View v)
{
// To send a result, simply call setResult() before your
// activity is finished.
setResult(RESULT_OK, (new Intent()).setAction("Corky!"));
finish();
}
};

This code should work according many examples. And it should return
RESULT_OK after btnOK clicked but after I click this button it only
closes ShowVideo  Activity.

Please help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---