Ani*_*ban 5 android android-notifications
我想在我的机器人中显示警报就像桌面上的gmail通知一样

我该怎么办?
解决方案让它显示如下

ama*_*Bit 10
没有活动就无法触发对话框.
因此,您可以使用对话框主题创建活动.
    <activity android:theme="@android:style/Theme.Dialog" />
现在从您的服务..只有当您的通知到达时才调用此活动...它会像对话框一样弹出...
编辑:
在调用您的活动时:
   startActivity(intent);
   overridePendingTransition(R.anim.enter_anim, R.anim.right_exit_anim);
现在在资源目录中名为anim的单独文件夹中创建两个动画文件.
enter_anim:
   <?xml version="1.0" encoding="utf-8"?>
   <set xmlns:android="http://schemas.android.com/apk/res/android"    
        android:interpolator="@android:anim/accelerate_decelerate_interpolator">
   <translate
    android:fromYDelta="20%p" //this takes val from 0(screenbottom) to 100(screentop).
    android:toYDelta="0%p"  //this takes val from 0(screenbottom) to 100(screentop).
    android:duration="700"   //transition timing
    />
   </set>
exit_anim:
   <?xml version="1.0" encoding="utf-8"?>
   <set xmlns:android="http://schemas.android.com/apk/res/android"    
        android:interpolator="@android:anim/accelerate_decelerate_interpolator">
   <translate
    android:fromYDelta="0%p" //this takes val from 0(screenbottom) to 100(screentop).
    android:toYDelta="20%p"  //this takes val from 0(screenbottom) to 100(screentop).
    android:duration="700"   //transition timing
    />
   </set>
编辑2:
创建一个活动..设计它..然后转到你的清单文件..并在你的活动标签下..添加:
    <activity android:theme="@android:style/Theme.Dialog" />
现在你的活动看起来就像一个对话......
编辑3:
现在在onCreate()之后在您的活动(对话框)中添加以下函数:
    @Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();
    View view = getWindow().getDecorView();
    WindowManager.LayoutParams lp = (WindowManager.LayoutParams) view.getLayoutParams();
    lp.gravity = Gravity.RIGHT | Gravity.BOTTOM;//setting the gravity just like any view
    lp.x = 10;
    lp.y = 10;
    lp.width = 200;
    lp.height = 100;
    getWindowManager().updateViewLayout(view, lp);
}
我们将覆盖附加窗口以指定屏幕上的活动位置.
现在,您的活动将放置在屏幕的右下方.
编辑4:
现在给出对话框的指定坐标点,使用lp.x和lp.y ...