应用它没有做任何事情.....? [英] App it not doing.....anything?

查看:182
本文介绍了应用它没有做任何事情.....?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code这个新的通知,我试着写修修补补。好像它会更简单的事,但由于某种原因,它不是我同意。它没有给我任何东西。没有logcat中,在模拟器上没有输出。没有。因此,这里是修改code:

I am tinkering with the code for this new notification I'm trying to write. Seems like it would be more simple to do but for some reason its not agreeing with me. Its not giving me anything. No logcat, no output on the emulator. Nothing. So here is the modified code:

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RemoteViews;

public class kickStart extends Activity {
NotificationManager nm;
Context context = this;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification();
    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.note);
    contentView.setImageViewResource(R.id.icon, R.drawable.ic_launcher);
    contentView.setTextViewText(R.id.title, "Custom notification");
    contentView.setTextViewText(R.id.text, "This is a custom layout");
    notification.contentView = contentView;
    Intent notificationIntent = new Intent(this, MainActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    notification.contentIntent = contentIntent;
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    nm.notify(R.id.layout, notification);
}
}

logcat的没有给我这就像应用程序甚至不存在的任何信息,但它说它安装。

Logcat is not giving me any info Its like the app don't exist even though its saying it installed.

下面是其他一些有用的信息:

Here is some other useful info:

[2012-07-22 12:57:21 - this1] Android Launch!
[2012-07-22 12:57:21 - this1] adb is running normally.
[2012-07-22 12:57:21 - this1] Performing com.example.this1.kickStart activity launch
[2012-07-22 12:57:21 - this1] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'test'
[2012-07-22 12:57:21 - this1] Uploading this1.apk onto device 'emulator-5554'
[2012-07-22 12:57:23 - this1] Installing this1.apk...
[2012-07-22 12:57:31 - this1] Success!
[2012-07-22 12:57:32 - this1] Starting activity com.example.this1.kickStart on device emulator-5554
[2012-07-22 12:57:33 - this1] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.this1/.kickStart }

因此​​安装它知道它只是不会运行一个发射器...

So it installs it knows of a launcher it just wont run...

推荐答案

尝试一个图标和tickerText设置您的通知:

Try setting an icon and tickerText to your notification:

notification.icon = R.drawable.small_notification;
notification.tickerText = "Text that scrolls across the status bar";

那么,tickerText是可选的,但需要的图标。 (这是有道理的,当我想它,因为不然我们怎么会看到在状态栏中的通知?)

Well, the tickerText is optional, but the icon is required. (Which makes sense when I think about it because how else would we see the notification in the status bar?)

通知的文档:

具有无效图标资源通知将不会显示。

notifications with an invalid icon resource will not be shown.

这篇关于应用它没有做任何事情.....?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆