相关疑难解决方法(0)

通知中的内存使用量很大

我正在开发一个带有服务的应用程序,该服务显示通知区域中的计时器的进度(带有进度条和文本).我已经在下面提取了一个具有相同问题的简单示例.

服务代码:

public class TNService extends Service {
    private NotificationManager nm;
    private Notification notification;
    private RemoteViews remoteView;

    @Override
    public void onCreate () {
        nm = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
        notification = new Notification(android.R.drawable.stat_sys_download, 
                "My notification", 
                System.currentTimeMillis());
        remoteView = new RemoteViews(this.getPackageName(),
                R.layout.notification);
        remoteView.setImageViewResource(R.id.icon, android.R.drawable.stat_sys_download);
        remoteView.setTextViewText(R.id.text, "");
        remoteView.setProgressBar(R.id.progress, 100, 0, false);
        notification.flags = Notification.FLAG_NO_CLEAR;
        notification.contentView = remoteView;
        notification.contentIntent = PendingIntent.getActivity(this, 0, new Intent(this,
                TNActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);

        Timer timer = new Timer ();
        timer.schedule(new TNTask(this), 0, 200);
    }

    @Override
    public IBinder onBind(Intent arg0) {
        return null; …
Run Code Online (Sandbox Code Playgroud)

java service notifications android

10
推荐指数
2
解决办法
3611
查看次数

Android-下载文件+状态栏通知放慢手机速度

我目前有一个asynctask从服务器下载mp3.当用户开始下载时,会创建状态栏通知.这将实时显示下载进度.我唯一担心的是手机放慢了几乎.有没有办法延迟显示的进度或使我的代码更快的方法?谢谢.

代码如下:

public class DownloadFile extends AsyncTask<String, String, String> {
    CharSequence contentText;
    Context context;
    CharSequence contentTitle;
    PendingIntent contentIntent;
    int HELLO_ID = 1;
    long time;
    int icon;
    CharSequence tickerText;
    File file;

    public void downloadNotification() {
        String ns = Context.NOTIFICATION_SERVICE;
        notificationManager = (NotificationManager) getSystemService(ns);

        icon = R.drawable.sdricontest;
        //the text that appears first on the status bar
        tickerText = "Downloading...";
        time = System.currentTimeMillis();

        notification = new Notification(icon, tickerText, time);

        context = getApplicationContext();
        //the bold font
        contentTitle = "Your download is in …
Run Code Online (Sandbox Code Playgroud)

notifications android download slowdown android-asynctask

5
推荐指数
2
解决办法
1万
查看次数

Android通知进度条冻结

这是我正在使用的代码

http://pastebin.com/3bMCKURu

问题是,经过一段时间(文件获得更多权重)通知栏下拉速度变慢,最后它就冻结了!

java notifications android progress-bar

4
推荐指数
2
解决办法
2844
查看次数