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
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"
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
Use Service for that
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.getApplicationContext().startActivity(intent);
below is some code`
public class HomepopupDataService extends Service {
private static final String TAG = "HomepopupDataService";
@Override
public void onCreate() {
Log.i(TAG, "Service onCreate");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Log.i(TAG, "Service onStartCommand");
CountDownTimer dlgCountDown;
Log.e("---------------", "onHandleIntent");
dlgCountDown = new CountDownTimer(10000, 1000) {
public void onTick(long millisUntilFinished) {
Log.e("---------------", "onHandleIntent++");
}
public void onFinish() {
Intent i = new Intent(getApplicationContext(),
DialogActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(i);
}
}.start();
return super.onStartCommand(intent, flags, startId);
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
Log.i(TAG, "Service onBind");
return null;
}
@Override
public void onDestroy() {
Log.i(TAG, "Service onDestroy");
}
}
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!