小编vbm*_*n11的帖子

Android通知不会发出声音或振动

int icon = R.drawable.icon;  
Context context = getApplicationContext();    
CharSequence contentTitle = "My notification";  
CharSequence contentText = "Countdown Complete!";     
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent();
Notification notification = new Notification(icon, "is completed!", System.currentTimeMillis());  
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, contentTitle, contentText, pendingIntent);
long[] vibrate = {0,100,200,300};
notification.vibrate = vibrate;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.defaults |= Notification.DEFAULT_SOUND; 
notificationManager.notify(myCountDown.getId(), notification);
Run Code Online (Sandbox Code Playgroud)

这个代码在我的Android应用程序中,我收到通知但没有声音或振动.

我已经在多部手机上进行了测试,声音和振动都在设置中打开和关闭.我也确定我要求在android清单中使用振动许可但我仍然只收到通知......

我也尝试过:

notification.defaults = Notification.DEFAULT_ALL;
Run Code Online (Sandbox Code Playgroud)

notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.defaults |= Notification.DEFAULT_SOUND;
Run Code Online (Sandbox Code Playgroud)

如何在通知中获得声音和振动?

java notifications android

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

"'='附近的语法不正确"运行时错误c#asp.net

SqlConnection sqlConnection = new SqlConnection(sqlConnectionString);
SqlCommand command = new SqlCommand();

command.CommandText = 
   "INSERT INTO [Users] 
    VALUES (Username=@username, Firstname=@firstname
          , Lastname=@lastname, ProfilePic=NULL, Bio=@bio, Email=@email
          , EmailIsVerified=@emailverified, Hash=@hash, CompanyID=@companyid)";
command.Parameters.AddWithValue("@username", m_username);
command.Parameters.AddWithValue("@firstname", m_firstname);
command.Parameters.AddWithValue("@lastname", m_lastname);
command.Parameters.AddWithValue("@bio", m_bio);
command.Parameters.AddWithValue("@email", m_email);
command.Parameters.AddWithValue("@emailverified", (m_emailIsVerified ? "yes" : "no"));
command.Parameters.AddWithValue("@hash", m_hash);
command.Parameters.AddWithValue("@companyid", m_companyID);
command.CommandType = CommandType.Text;
command.Connection = sqlConnection;

sqlConnection.Open();

command.ExecuteNonQuery();

sqlConnection.Close();
Run Code Online (Sandbox Code Playgroud)

使用上面的代码我得到"语法错误near ="错误.我做错了什么?

c# sql asp.net

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

c ++声明该类中的类的变量

我有以下代码:

template <typename T>
class Node{
public: 
    Node<T>(T data){
        this->data = data;
    }
    T data;
    Node<T> left; 
    Node<T> right;
};
Run Code Online (Sandbox Code Playgroud)

但它不喜欢我如何拥有与它们所在类相同类型的成员变量,因为编译器不知道"Node"是什么.

c++ variables class

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

标签 统计

android ×1

asp.net ×1

c# ×1

c++ ×1

class ×1

java ×1

notifications ×1

sql ×1

variables ×1