Android弹出式屏幕,如WhatsApp或Telegram

Android弹出式屏幕,如WhatsApp或Telegram,android,service,popup,lockscreen,whatsapp,Android,Service,Popup,Lockscreen,Whatsapp,我是android开发的新手。 我找了很多,但没有找到正确的答案。 我想制作一个弹出/对话框屏幕,在服务发生某些事情时显示 当手机锁定时,此屏幕也应可用。 我已经发现,您可以创建对话框样式的活动或具有透明背景的活动。但我认为这不是正确的方法。 以下是其中一个屏幕(右侧): 您可以滚动浏览所有消息并回复所有消息。 我的调试手机有安卓4.0.2(所以是API级别14),我希望这是我的应用程序的最低要求 编辑: 谢谢你的回复,但我已经测试了通知。 问题是,通知栏中只显示smallicon。 我没有收到

我是android开发的新手。 我找了很多,但没有找到正确的答案。 我想制作一个弹出/对话框屏幕,在服务发生某些事情时显示

当手机锁定时,此屏幕也应可用。 我已经发现,您可以创建对话框样式的活动或具有透明背景的活动。但我认为这不是正确的方法。 以下是其中一个屏幕(右侧):

您可以滚动浏览所有消息并回复所有消息。 我的调试手机有安卓4.0.2(所以是API级别14),我希望这是我的应用程序的最低要求

编辑: 谢谢你的回复,但我已经测试了通知。 问题是,通知栏中只显示smallicon。 我没有收到通知窗口或带有标题或内容的弹出窗口。。。 下面是我的实现:

import com.google.android.gms.gcm.GoogleCloudMessaging;
import android.app.IntentService;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;

public class GcmIntentService extends IntentService {
    public static final int NOTIFICATION_ID = 1;


    public GcmIntentService() {
        super("GcmIntentService");
    }

    public static final String TAG = "GCM test";

    @Override
    protected void onHandleIntent(Intent intent) {
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        String messageType = gcm.getMessageType(intent);
        if (!intent.getExtras().isEmpty()) {  // has effect of unparcelling Bundle
            if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
                sendNotification("Send error: " + intent.getExtras().toString());
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
                sendNotification("Deleted messages on server: " + intent.getExtras().toString());
                // If it's a regular GCM message, do some work.
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                // Post notification of received message.
                sendNotification("message:\n" + intent.getStringExtra("message"));
                Log.i(TAG, "Received: " + intent.getExtras().toString());
            }
        }
        // Release the wake lock provided by the WakefulBroadcastReceiver.
        GcmBroadcastReceiver.completeWakefulIntent(intent);
    }

    private void sendNotification(String msg) {
        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.ic_check)
                        .setContentTitle("My notification")
                        .setContentText(msg);
        Intent resultIntent = new Intent(this, PopupMessageActivity.class);
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        stackBuilder.addParentStack(PopupMessageActivity.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent =
                stackBuilder.getPendingIntent(
                        0,
                        PendingIntent.FLAG_UPDATE_CURRENT
                );
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }
}

通知是您需要的

以下是android开发者页面的链接:

祝酒也可能对你有所帮助:


祝你好运

您指的是运行在
锁屏上的应用程序小部件
.. 所以你可以阅读这一页并使用它

您使用的是什么语言/环境?对不起。。。android studioSorry,我用的是cordova,但是@Meghdeep Ray的回答应该会有帮助。@Signare是的。当然,这取决于您设置的长度。