小编Cee*_*eRo的帖子

如何恢复通知而不重新创建活动?

我想我已经想到了这个问题,但在对这个问题进行一些调试之后:如何使通知无法删除/不可删除我刚刚意识到我的活动仍以随机顺序进入onCreated()和onDestroyed().

我的活动清单:

<activity
        android:name="***.***.***.*****"
        android:configChanges="orientation|keyboardHidden"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:launchMode="singleTop" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

我也尝试过launchmodes singleTask,singleInstance.

我的通知意图代码:

Intent intent = new Intent(context, MyClass.class);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    //intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    //intent.setFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
    //intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我已经尝试过看起来可能相关的每一面旗帜,但没有运气......

这会产生一些不需要的伪像,例如每次单击通知时重新启动AlarmManager并触发alarmmanager start-task.我想避免这种情况.

有什么建议?

编辑:我知道有很多像这样的问题,但提供的解决方案似乎没有在这里做到这一点......:/

Edit2:根据要求,这是我的班级:

package ***.***.***;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log; …
Run Code Online (Sandbox Code Playgroud)

notifications android oncreate ondestroy

23
推荐指数
3
解决办法
2万
查看次数

C#HttpClient PUT

出于某种原因,我现在使用的下面的代码因此引发了一个异常:

public static async Task<string> HttpPut(string inUrl, string inFilePath)
    {
        using (var handler = new HttpClientHandler
        {
            AllowAutoRedirect = false
        })
        {
            using (var client = new HttpClient(handler))
            {
                //var content = new StreamContent(new FileStream(inFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, useAsync: true));
                using (var content = new StreamContent(new FileStream(inFilePath, FileMode.Open)))
                {
                    content.Headers.Remove("Content-Type");
                    content.Headers.Add("Content-Type", "application/octet-stream");

                    using (var req = new HttpRequestMessage(HttpMethod.Put, inUrl))
                    {
                        string authInfo = String.Format("{0}:{1}", Program.Config.MediaStorageList.Find(o => o.Name == "Viz Media Engine Test").UserName, Program.Config.MediaStorageList.Find(o => o.Name == "Viz Media …
Run Code Online (Sandbox Code Playgroud)

c# http put httpclient

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

如何使通知无法删除/不可删除

即使用户点击它或点击全部清除,我也想让我的Android通知停留...

现在它有时停留,有时会被删除,我不确定是什么原因造成的.

这是我的通知代码:

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void createNotification()
{
    NotificationManager notificationManager = (NotificationManager)context.getSystemService(NOTIFICATION_SERVICE);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                            .setContentTitle("Wolftech Field Agent")
                            .setContentText("Getting Status")
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setOngoing(true)
                            .setAutoCancel(false);

    Intent intent = new Intent(context, FieldAgent.class);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    stackBuilder.addParentStack(FieldAgent.class);
    stackBuilder.addNextIntent(intent);

    PendingIntent pendingIntent = stackBuilder.getPendingIntent(0,  PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(pendingIntent);

    notificationManager.notify(NOTIFICATION_ID, builder.build());
}

public static void updateNotificationText(String inString)
{
    NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                                            .setContentText(inString)
                                            .setContentTitle("Wolftech Field Agent")
                                            .setSmallIcon(R.drawable.ic_launcher)
                                            .setOngoing(true)
                                            .setAutoCancel(false);

    Intent intent = new Intent(context, FieldAgent.class);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    TaskStackBuilder …
Run Code Online (Sandbox Code Playgroud)

notifications android

6
推荐指数
2
解决办法
8598
查看次数

如何从时间码或帧号中找到 .mp4 文件中的字节偏移量?

我正在读取一个 .mp4 文件,并通过网络将它们提供给客户端/播放器。

如果客户端跳到尚未收到的视频部分,它会将 time 或 frame# 发送回服务器,我想从文件的那部分开始读取。

我已经阅读了很多内容并查看了 BmffViewer 以及 BmffViewer 的源代码,但是我仍然不知道如何找到偏移量。

文件的内容都将采用相同的格式(h.264 vid、aac sound)。mdat 位于看起来像的文件的末尾,但它们似乎仍然立即开始播放。

这是来自 BmffViewer 的 ftyp 和文件结构的图片:

这是来自 MediaInfo 的图片:

任何人都可以提供一些示例代码或至少指出我正确的方向吗?现在开始阅读 ISO 规范还为时过早......

谢谢

c# mp4 aac offset h.264

0
推荐指数
1
解决办法
2386
查看次数

标签 统计

android ×2

c# ×2

notifications ×2

aac ×1

h.264 ×1

http ×1

httpclient ×1

mp4 ×1

offset ×1

oncreate ×1

ondestroy ×1

put ×1