views:

254

answers:

3

Hi all,

I'm writing an Android application and I would like to place a dialog or view over the home screen so that a user can enter text without jumping into my full application. I can't seem to get this to work. If I present a dialog (even in a transparent activity), my application launches.

If you don't know what I'm talking about, take a look at the Facebook widget. I want to replicate a similar behavior to the clicking on the "What's on your mind?" box.

Thanks for any help in advance!

-Brian

+4  A: 

They are launching an activity, but they've set the activity's theme so it looks like a Dialog.

In your manifest, you have to add something like this under the <activity> tag: android:theme="@android:style/Theme.Dialog"

Al
Thanks, but how do I start an activity from my app widget? I can't seem to figure out pending intents. Thanks!
Brian515
A: 

Thanks a lot, I tried with Theme.Dialog

  <activity android:name=".language"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Dialog">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>

But in my code, there is 2 different floating windows : my layout and the tile. Here is the following code:

import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.app.Dialog; 

public class language extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       // setContentView(R.layout.main);
        Dialog dialog = new Dialog(this); 
        dialog.setContentView(R.layout.main); 
        dialog.setTitle("Raygional"); 
        dialog.show();

    }
}

PS : I know this should be a question rather than an answer

raychenon
then why did you post it as an answer?
Lo'oris
It may interest others who want to do a Dialog over homescreen.
raychenon
A: 

My problem was that the application always launched to display the dialog.

To solve this, I set the activity lauch mode to singleInstance in the manifest. Now it shows the dialog over the home screen!

Brian515