小编Ano*_*ous的帖子

如何发出呼叫号码的通知?

我希望它pendingIntent在单击屏幕上显示“通知”的按钮后创建通知。因此,当用户单击通知时,它会拨打类似 021-1234567 的号码。我该怎么做呢?

我一直在网上寻求帮助,但似乎找不到任何与此相关的信息。

public void notifyPendingIntent(View view) {

    Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+ 0211234567));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

    PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);

    // Build notification
    Notification notify = new Notification.Builder(this)
            .setContentTitle("Make this call")
            .setContentText("New call must be made to 021 123 4567")
            .setTicker("New Alert")
            .setContentIntent(pIntent).build();
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    // hide the notification after its selected
    notify.flags |= Notification.FLAG_AUTO_CANCEL;

    notificationManager.notify(0, notify);
}
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经有了这个,但是当我按下按钮时,什么也没有发生。

我试过了,现在可以用了。感谢所有试图提供帮助的人。

public void notifyPendingIntent(View view) {

    NotificationCompat.Builder myNotification = new NotificationCompat.Builder(this) …
Run Code Online (Sandbox Code Playgroud)

notifications android android-intent android-phone-call

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

如何将这些数字存储在C中?

让我们说你有一个像这样的阵列

{ 1 2 5 7 2 3 7 4 2 1 }
Run Code Online (Sandbox Code Playgroud)

并且你想存储数组的前半部分和后半部分之间的差异在位置2和4.

诀窍是,我需要稍后在其他代码中使用这些存储的数字,所以我无法弄清楚我将如何存储这些数字.

我有这个方法

int * getPositions(int *array, int size){
    int * c[(size/2)];
    int counter = 0;
    for(int i = 0; i < size /2; i++) {
        if (*(array + i) != *(array + (size - 1) - i)) {
            c[counter]= (int *) i;
            counter++;
        }
    }return (int *) c;
 }
Run Code Online (Sandbox Code Playgroud)

但它似乎存储-1774298560在每个位置.当我尝试打印它时,我知道原因

int c = (int) getPositions(array, size_of_array);

for(int i = 0; i < ((size_of_array/2)); i++){ …
Run Code Online (Sandbox Code Playgroud)

c arrays

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