How to hide activity from menu?

by f...@r@0n » Mon, 12 Oct 2009 02:48:48 GMT


Sponsored Links
 Hello guys,

Does anybody know how to hide activity icon from menu? I am trying to
write simple multiview application. So, I have two activities there,
the first (main) activity starts the second one. However, my second
activity icon is visible in installed apps menu grid and can be
started from menu as separate standalone app :)
Is there any special activity tag I can use in manifest to hide icon?

Thanks.

Br,
 Faraon

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



How to hide activity from menu?

by Mark Murphy » Mon, 12 Oct 2009 03:07:02 GMT


 


In the AndroidManifest.xml file, both of your activities probably have
an <intent-filter> element that looks like:

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

That tells Android to put an icon in the Launcher for that activity.
Remove that <intent-filter> from any activity that is not supposed to be
in the Launcher.

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

Need Android talent? Ask on HADO!  http://wiki.andmob.org/hado 

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


Sponsored Links


How to hide activity from menu?

by f...@r@0n » Mon, 12 Oct 2009 22:35:01 GMT


 Yeah, removing LAUNCHER category works fine. This is what I need.

Such kind of things always happen when copy-paste code without clear
understanding what you are doing. Will try to avoid this in future :)

Thanks again!

f...@r@0n
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Animate the resize (not scale) of a view or layout?

Hello,

I'm trying to resize a layout over time (like an animation) however I
do not want the view to scale, only resize it's bounding box. If the
view is to small to contain the children, the children would simply be
clipped. I can set the layout to various sizes on load however I can't
seem to figure out how to do it dynamically over time.

Is there an existing way I can use the animation framework to achieve
this?

Thanks.
--~--~---------~--~----~------------~-------~--~----~

2. Quick Yes/No question about the UI thread during a screen rotation

If I remember correctly, if you post a Runnable to a Handler instance
(AsyncTask does this), the messages(/Runnables) are posted back to
your application on the main UI-thread, regardless whether your
activity is active or destroyed.

You do have to check *which* Activity instance is active (or maybe
even none) when the onPostExecute is being called. For this, i use a
static reference to my current activity:

class MyActivity extends Activity {
  ...
  // A single static reference to the currently active
  // activity (note: this is only fool-proof when only one
  // instance at the same time (for a process) can be active)
  private static MyActivity ACTIVE_INSTANCE = null;
  ...

  @Override
  protected void onCreate() {
    ACTIVE_INSTANCE = this;
    super.onCreate();
    ...
  }


  @Override
  protected void onDestroy() {
    ...
    super.onDestroy();
    ACTIVE_INSTANCE = null;
  }

  ...
}

And from within your onPostExecute, you'd use ACTIVE_INSTANCE to show
any updates in the user-interface. Be sure to check if it is null or
not.

Note that is has bitten me in the past a few times using an inner
class that is a subclass of AsyncTask and implicitly referring back to
the Activity that started the AsyncTask. e.g. (ommitting the
generics):

public MyActivity extends Activity {
  private TextView mMyTextView;
  ...
  ...

  public void someMethod(SomeInput input) {
    AsyncTask runInBackground = new AsyncTask() {
      protected Result doInBackground (Params... params) {
        ... do your background stuff here ...
      }

      protected void onPostExecute (String result) {
        ...
        mMyTextView.setText(result);
        ...
      }
    };
    runInBackground.execute(input);
  }
  ...
  ...
}

The problem was that mMyTextView refers to the TextView in an Activity
that may have been destroyed when onPostExecute is called. Instead:

public MyActivity extends Activity {
  private TextView mMyTextView;
  ...
  ...
  private static MyActivity ACTIVE_INSTANCE = null;
  ...

  @Override
  protected void onCreate() {
    ACTIVE_INSTANCE = this;
    super.onCreate();
    ...
  }


  @Override
  protected void onDestroy() {
    ...
    super.onDestroy();
    ACTIVE_INSTANCE = null;
  }

  ...

  public void someMethod() {
    AsyncTask runInBackground = new AsyncTask() {
      protected Result doInBackground (Params... params) {
        ... do your background stuff here ...
      }

      protected void onPostExecute (String result) {
        if (ACTIVE_INSTANCE == null)
          return;
        ...
        ACTIVE_INSTANCE.mMyTextView.setText(result);
        ...
      }
    };
    runInBackground.execute(input);
  }
  ...
  ...
}



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

3. i can't see my samsung galaxy on windows seven 64 bits

4. packaging multiple APKs

5. Verizon attacks iPhone with new 鈥楧roid鈥?campaign

6. How to find device idle state:

7. Issue with Accelerometer notification when there is higher volume audio play: