2

我在developers.android.com 上找到了以下代码,但AIDE 将某些事情标记为错误。我应该怎么做才能修复这些错误?

TaskStackBuilder 实体说不明确的导入类型(其中 2 个)

StackBuilder 的未知变量类型(其中 3 个)

未知实体 StackBuilder(其中 3 个)

NotificationCompat.Builder myBuilder = new NotificationCompat.Builder(this) 
    .setSmallIcon(R.drawable.ic_launcher) 
    .setContentTitle("My notification") 
    .setContentText("Hello World!"); 

Intent resultIntent = new Intent(this, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); 
stackBuilder.addParentStack(ResultActivity.class); 
stackBuilder.addNextIntent(resultIntent); 

PendingIntent resultPendingIntent = stackBuilder.getPendingIntent( 0, PendingIntent.FLAG_UPDATE_CURRENT ); 
myBuilder.setContentIntent(resultPendingIntent); 

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
mNotificationManager.notify(mId, myBuilder.build());
4

0 回答 0