小编Nik*_*dze的帖子

NotificationManager.cancel(id)在广播接收器内不起作用

Android:我正在尝试在安装软件包后取消通知栏中的通知.我正在做的是以下内容:

 public class MyBroadcastReceiver extends BroadcastReceiver {

                private static final String TAG = "MyBroadcastReceiver";

                @Override
                public void onReceive(Context context, Intent intent) {
                    String action = intent.getAction();
                    if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
                        Uri data = intent.getData();
                        //some code goes here
                        //get the id of the notification to cancel in some way
                        notificationhelper._completeNotificationManager.cancel(id);     
                        }
                }
            }
Run Code Online (Sandbox Code Playgroud)

哪里

public class notificationhelper {
    public static NotificationManager _completeNotificationManager = null;

    public void complete() {        
        if (_completeNotificationManager == null)
            _completeNotificationManager = (NotificationManager) _context.getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = new Notification( …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver notificationmanager

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

如何在android中运行应用程序?

嗨,我想制作一个继续在后台运行的Android应用程序,当用户访问任何文件夹,图片或任何其他文件时,它通过使用toasts访问此文件(文件名).

service android broadcastreceiver

9
推荐指数
1
解决办法
3万
查看次数

MySQL Workbench EER图表编辑中的插入选项卡是什么?

我需要将一些初始(默认)数据插入到一个新数据库中,我在MySQL Workbench EER Diagram表编辑表单上找到了这个Inserts选项卡

表格编辑 - 插入

我的假设是我可以使用它来插入初始(默认)数据,这些数据将在同步期间传播到数据库(不确定它将如何与数据库中的任何现有数据合并,但是......).我添加了几行和同步模型与空数据库,但没有插入数据.

那么,我的问题是"表格编辑"界面上的"插入"选项卡什么?

我使用MySQL Workbench 6.

PS如果有人也可以指出插入初始(默认)数据的简单方法(除了简单地运行SQL脚本),我将不胜感激.

谢谢.

mysql database-design mysql-workbench

9
推荐指数
1
解决办法
4880
查看次数

如何在android中中止BroadcastReceiver

我正在制作一个短信计划应用程序,它只需要用户的时间,短信和号码,并在给定时间发送短信.我在用PendingIntent.这是我的示例代码.

当用户创建计划时,它只是调用此方法.

private void SendMessages()
    {
        Intent intent = new Intent(this, SMSBroadcastReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(
                this.getApplicationContext(), 234324243, intent, 0);

        AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
        alarmManager.set(AlarmManager.RTC_WAKEUP, Timemilli, pendingIntent);
    }
Run Code Online (Sandbox Code Playgroud)

这是'SMSBroadcastReceiver.java'文件

public class SMSBroadcastReceiver extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        Toast.makeText(context, "SMS Sent !!!!.", Toast.LENGTH_LONG)
                .show();
        // //Sms Sending

        try
        {
            SmsManager smsManager = SmsManager.getDefault();
            for (int i = 0; i < SMSScheduleContactsActivity.SelectedContacts.length; i++)
            {
                smsManager.sendTextMessage(
                        SMSScheduleContactsActivity.SelectedContacts[i], null,
                        AddNewSmsSchedule.Message, null, null);
            }

            Log.d("testllllllllllllllll", "Message …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver android-pendingintent smsmanager

8
推荐指数
2
解决办法
4088
查看次数

使用AttributeRouting在WebAPI中指定默认控制器/操作路由

如何设置使用AttributeRouting时使用的默认控制器,而不是WebAPI使用的默认RouteConfiguration.即删除注释的代码部分,因为使用AttribteRouting时这是多余的

    public class RouteConfig
    {
       public static void RegisterRoutes(RouteCollection routes)
       {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        //routes.MapRoute(
        //    name: "Default",
        //    url: "{controller}/{action}/{id}",
        //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        //);

       }
     }
Run Code Online (Sandbox Code Playgroud)

如果我评论上面的部分并尝试运行webapi应用程序,我会收到以下错误,因为没有定义默认的Home控制器/操作. HTTP错误403.14 - 禁止Web服务器配置为不列出此目录的内容.

如何通过归属控制器/操作的属性路由指定路由?

编辑:代码示例:

 public class HomeController : Controller
{
    [GET("")]
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult Help()
    {
        var explorer = GlobalConfiguration.Configuration.Services.GetApiExplorer();
        return View(new ApiModel(explorer));
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-web-api attributerouting

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

Windows 服务应用程序中自托管 ASP.NET Web API 的问题

我在网上看到了一些文章,描述了如何在 Windows 服务应用程序中自行托管 ASP.NET Web API(请参阅此处此处)。我在 VB.NET 中编写了一些简单的代码,以便在服务启动时启动自主机,并在服务停止时停止它,如下所示:

Protected Overrides Sub OnStart(ByVal args() As String)
    Try
        ' init a new self host configuration using the base address
        _config = New HttpSelfHostConfiguration(New Uri("http://localhost:8080"))

        ' map the URLs into the config
        MapRoutes(_config)

        _server = New HttpSelfHostServer(_config)
        ' start the server and wait for requests
        _server.OpenAsync()

    Catch ex As Exception
        Throw
    End Try
End Sub

Protected Overrides Sub OnStop()
    Try
        _server.CloseAsync().Wait()
        _server.Dispose()
    Catch ex As Exception
        Throw
    End Try …
Run Code Online (Sandbox Code Playgroud)

vb.net asp.net-web-api

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

Google的智能更新技术如何运作?

我知道基础知识:他们计算两个版本之间的差异,并将其发送到部署它的用户设备.确切地说,我对2个问题感兴趣:

  1. 对服务器软件进行了哪些更改以及对Android Google Play商店应用程序进行了哪些更改?
  2. 使用什么算法来计算两个应用程序版本之间的差异?

谢谢.

diff android updates delta

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

如何使用InterceptAttribute使用Ninject拦截

我有一个NinjectWebCommon如下.我无法让TimingInterceptor在具有"Timing"属性集的方法上触发.如果拦截器是在类级别定义的,其中所有方法调用都将被截获,它可以正常工作,但我希望能够指定我想拦截的方法(选择加入).

我确实添加了Ninject.Extensions.Interception.DynamicProxy.

public static class NinjectWebCommon 
{
    private static readonly Bootstrapper bootstrapper = new Bootstrapper();

    /// <summary>
    /// Starts the application
    /// </summary>
    public static void Start() 
    {
        DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
        DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
        bootstrapper.Initialize(CreateKernel);
    }

    /// <summary>
    /// Stops the application.
    /// </summary>
    public static void Stop()
    {
        bootstrapper.ShutDown();
    }

    /// <summary>
    /// Creates the kernel that will manage your application.
    /// </summary>
    /// <returns>The created kernel.</returns>
    private static IKernel CreateKernel()
    {
        var NinjectSettings = new NinjectSettings();
        var kernel = new …
Run Code Online (Sandbox Code Playgroud)

c# aop ninject ninject-extensions ninject-interception

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

Android MediaPlayer.OnBufferingUpdateListener - 缓冲内容的百分比为负数

我有一个MediaPlayer用于流式传输互联网广播的服务:

public class MediaPlayerService extends Service implements 
    MediaPlayer.OnPreparedListener,
    MediaPlayer.OnBufferingUpdateListener {

    private MediaPlayer mMediaPlayer;
    private WifiLock mWifiLock;

    public int onStartCommand(Intent intent, int flags, int startId) {
        mMediaPlayer = new MediaPlayer();

        mMediaPlayer.setOnBufferingUpdateListener(this);
        mMediaPlayer.setOnPreparedListener(this);

        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.setDataSource(MY_URL);

        // Acquire CPU lock and wi-fi lock

        mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
        mWifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE))
             .createWifiLock(WifiManager.WIFI_MODE_FULL, "Media Player Wi-Fi Lock");
        mWifiLock.acquire();

        mMediaPlayer.prepareAsync();

        return START_STICKY;
    }

    @Override
    public void onPrepared(MediaPlayer mediaPlayer) {
        mMediaPlayer.start();
    }

    @Override
    public void onBufferingUpdate(MediaPlayer mp, int percent) {
        Log.d("Buffered " + percent);
    }
} …
Run Code Online (Sandbox Code Playgroud)

java android buffering android-service android-mediaplayer

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

带把手的 Mandrill 模板 - 如何格式化日期

Mandrill 有一项很棒的功能,它允许人们在模板中使用 Handlebars 来自定义电子邮件内容。请参阅此处的文档。

Madnrill 支持的助手之一是date可以像{{#date}}. 默认日期格式为d/m/Y. 我的问题是如何指定不同的日期格式(例如yyyy)?

我需要显示类似2015 Name. 我试过:

  • {{#date yyyy}} Name- 显示05/31/15(默认格式,似乎删除了它之后的任何 HTML)。
  • {{#date 'yyyy'}} Name- 显示{{#date 'yyyy'}} Name(无法解析)。
  • {{#date yyyy}}{{/date}} Name- 显示05/31/15 Name(默认格式)。
  • {{#date 'yyyy'}}{{/date}} Name- 显示{{#date 'yyyy'}}{{/date}} Name(无法解析)。

感谢您的帮助;)

email-templates date-formatting handlebars.js mandrill

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