Intent i = new Intent(context,MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
context.startActivity(i);能正常启动 但是发现第一次点back键onKeyDown中并没有收到消息 ,除非点一下屏幕
请问如何处理呢才能让他立即获得焦点呢(不点击屏幕)?

解决方案 »

  1.   


    <LinearLayout
            android:focusable="true" android:focusableInTouchMode="true"
            android:layout_width="0px" android:layout_height="0px"/>
      

  2.   

    谢谢回答,这个不行呢,我程序刚一开始就是从Service启动,并没有焦点,为什么启动的Activity也没有焦点呢。。
      

  3.   

    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 这行去掉
      

  4.   

    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  ,这个是肯定不能去掉的。
    你的设置焦点是什么意思?