[android-developers] Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag

2012-11-18 Thread Francisco Marzoa

Hi,

I am getting many reports of crashes with this error condition:

android.util.AndroidRuntimeException: Calling startActivity() from 
outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. 
Is this really what you want?


The problem is that the reported stack does not made reference to any 
line on my own code:


0 android.util.AndroidRuntimeException: Calling startActivity() from 
outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. 
Is this really what you want?

1 at android.app.ContextImpl.startActivity(ContextImpl.java:618)
2 at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
3 at 
android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:236)

4 at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:331)
5 at android.os.Handler.dispatchMessage(Handler.java:99)
6 at android.os.Looper.loop(Looper.java:123)
7 at android.app.ActivityThread.main(ActivityThread.java:3652)
8 at java.lang.reflect.Method.invokeNative(Native Method)
9 at java.lang.reflect.Method.invoke(Method.java:507)
10 at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)

11 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12 at dalvik.system.NativeStart.main(Native Method)

So I am having real troubles to find the source of the problem.

Does anyone have any idea on what methods called from my code may raise 
these kind of errors?


TIA

--
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] Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag ?

2010-09-21 Thread A N K ! T
have u try to put this line after defining intent.
 browserIntent .setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);


On Tue, Sep 21, 2010 at 4:39 PM, mani  wrote:

> Hi all,
>
> I tried to create a edittextbox, and button next to it, in the status
> bar. !!
> I created it  and tried to launch the browser activity, when somebody
> enters a URL in the textbox & click that button.
>
> I get runtime exception as below.Can anyone please help what is the
> issue with this exception ?
> I know that Status bar is not a seperate activity. It is part of
> 'PhoneWindow'. But then i couldnt figure out what is the issue ?
> Framework experts coud you pls help here...!!
>
> E/AndroidRuntime(   70): *** FATAL EXCEPTION IN SYSTEM PROCESS:
> android.server.ServerThread
> E/AndroidRuntime(   70): android.util.AndroidRuntimeException: Calling
> startActivity() from outside of an Activity  context requires the
> FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
> E/AndroidRuntime(   70):at
> android.app.ContextImpl.startActivity(ContextImpl.java:617)
> E/AndroidRuntime(   70):at
> com.android.server.status.StatusBarService
> $1.onClick(StatusBarService.java:289)
> E/AndroidRuntime(   70):at
> android.view.View.performClick(View.java:
> 2408)
> E/AndroidRuntime(   70):at android.view.View
> $PerformClick.run(View.java:8816)
> E/AndroidRuntime(   70):at
> android.os.Handler.handleCallback(Handler.java:587)
> E/AndroidRuntime(   70):at
> android.os.Handler.dispatchMessage(Handler.java:92)
> E/AndroidRuntime(   70):at android.os.Looper.loop(Looper.java:123)
> E/AndroidRuntime(   70):at
> com.android.server.ServerThread.run(SystemServer.java:506)
>
>  private void makeStatusBarView(Context context) {
> 
> 
>urlTextbox = (EditText)sb.findViewById(R.id.urltextbox);
>Button  mButton = (Button) sb.findViewById(R.id.Go);
>mButton.setOnClickListener(new Button.OnClickListener(){
>public void onClick(View v) {
>System.out.println("Status Bar - Onclick of
> GO");
> String url = urlTextbox.getText().toString();
> Intent browserIntent = new
> Intent("android.intent.action.VIEW", Uri.parse(url));
> mContext.startActivity(browserIntent);
>}
>});
>
> --
> -
>
> }
>
> /frameworks/base/services/java/com/android/server/status/
> StatusBarService.java --> I was trying to implement it like this.
>
> status_bar.xml:
> 
>
> android:background="@drawable/statusbar_background"
>android:orientation="vertical"
>android:focusable="true"
>android:descendantFocusability="afterDescendants"
>>
>
>android:layout_width="match_parent"
>android:layout_height="match_parent"
>android:orientation="horizontal">
>
>android:layout_width="0dip"
>android:layout_weight="1"
>android:layout_height="match_parent"
>android:layout_alignParentLeft="true"
>android:paddingLeft="6dip"
>android:gravity="center_vertical"
>android:orientation="horizontal"/>
>
> android:hint="eg. www.google.com, "
>android:layout_width="150dip"
>android:layout_height="wrap_content"
>android:maxLines="1"/>
>
>android:layout_width="50dip"
>android:layout_height="wrap_content"
>android:text="@string/go"/>
>
>android:layout_width="wrap_content"
>android:layout_height="match_parent"
>android:layout_alignParentRight="true"
>android:paddingRight="6dip"
>android:gravity="center_vertical"
>android:orientation="horizontal"/>
>
>
>android:layout_width="match_parent"
>android:layout_height="match_parent"
>android:paddingLeft="6dip"
>android:animationCache="false"
>android:orientation="horizontal" >
>android:layout_width="wrap_content"
>android:layout_height="match_parent"
>android:layout_marginRight="8dip"
>>
>android:layout_width="25dip"
>android:layout_height="25dip"
>/>
>android:layout_width="25dip"
>android:layout_height="25dip"
>/>
>
>android:layout_width="0dip"
>android:layout_weight="1"
>android:layout_height="wrap_content"
>android:paddingTop="2dip"
>android:paddingRight="10dip">
>android:layout_width="match_parent"
>android:layout_height="wrap_content"
>  

[android-developers] Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag ?

2010-09-21 Thread mani
Hi all,

I tried to create a edittextbox, and button next to it, in the status
bar. !!
I created it  and tried to launch the browser activity, when somebody
enters a URL in the textbox & click that button.

I get runtime exception as below.Can anyone please help what is the
issue with this exception ?
I know that Status bar is not a seperate activity. It is part of
'PhoneWindow'. But then i couldnt figure out what is the issue ?
Framework experts coud you pls help here...!!

E/AndroidRuntime(   70): *** FATAL EXCEPTION IN SYSTEM PROCESS:
android.server.ServerThread
E/AndroidRuntime(   70): android.util.AndroidRuntimeException: Calling
startActivity() from outside of an Activity  context requires the
FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
E/AndroidRuntime(   70):at
android.app.ContextImpl.startActivity(ContextImpl.java:617)
E/AndroidRuntime(   70):at com.android.server.status.StatusBarService
$1.onClick(StatusBarService.java:289)
E/AndroidRuntime(   70):at android.view.View.performClick(View.java:
2408)
E/AndroidRuntime(   70):at android.view.View
$PerformClick.run(View.java:8816)
E/AndroidRuntime(   70):at
android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(   70):at
android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(   70):at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(   70):at
com.android.server.ServerThread.run(SystemServer.java:506)

 private void makeStatusBarView(Context context) {


urlTextbox = (EditText)sb.findViewById(R.id.urltextbox);
Button  mButton = (Button) sb.findViewById(R.id.Go);
mButton.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
System.out.println("Status Bar - Onclick of 
GO");
 String url = urlTextbox.getText().toString();
 Intent browserIntent = new
Intent("android.intent.action.VIEW", Uri.parse(url));
 mContext.startActivity(browserIntent);
}
});

--
-

}

/frameworks/base/services/java/com/android/server/status/
StatusBarService.java --> I was trying to implement it like this.

status_bar.xml:








 




















-- 
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