我想要片段中的Button Click事件的通知。 我尝试了很多,它没有给我任何错误,但它没有向我显示通知。
main.java
public class OneTimeTask extends Fragment implements View.OnClickListener {
public OneTimeTask() {
}
;
String addtask, adddetail, adddate;
static final int TIME_DIALOG_ID = 999;
View view;
EditText taskname, taskdetail, taskdate;
Button taskadd;
ProgressDialog mProgressDialog;
SessionManager session;
JSONObject jsonobject;
private DatePickerDialog fromDatePickerDialog;
private DatePickerDialog toDatePickerDialog;
private SimpleDateFormat dateFormatter;
String uid;
Intent intent;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_daily__task, container, false);
getActivity().setTitle("Task");
taskname = (EditText) view.findViewById(R.id.taskname);
taskdetail = (EditText) view.findViewById(R.id.taskdetail);
taskdate = (EditText) view.findViewById(R.id.taskdate);
taskadd = (Button) view.findViewById(R.id.taskaddtask);
GetCurrentGPSLocation gps = new GetCurrentGPSLocation(getActivity());
if (gps.canGetLocation()) {
// \n is for new line
}else {
// can't get location
// GPS or Network is not enabled
// Ask user to enable GPS/network in settings
gps.showSettingsAlert();
}
dateFormatter = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);
session = new SessionManager(getActivity());
HashMap<String, String> user = session.getUserDetails();
uid = user.get(SessionManager.KEY_ID);
setDateTimeField();
return view;
}
private void setDateTimeField() {
taskadd.setOnClickListener(this);
Calendar newCalendar = Calendar.getInstance();
fromDatePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
taskadd.setText(dateFormatter.format(newDate.getTime()));
}
},newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
}
// @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getActivity().getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void onClick(View view) {
if(view == taskadd) {
fromDatePickerDialog.show();
}
taskadd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addtask=taskname.getText().toString();
adddetail=taskdetail.getText().toString();
adddate= taskdate.getText().toString();
InsertData();
Notification();
}
});
}
public void Notification() {
// Set Notification Title
String strtitle = getString(R.string.notificationtitle);
// Set Notification Text
String strtext = getString(R.string.notificationtext);
// Open NotificationView Class on Notification Click
/*
FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction();
TabFragment mFrag = new TabFragment();
t.replace(com.Weal.sachin.omcom.R.id.framelayout, mFrag);
t.commit();
*/
Intent intent = new Intent(getActivity(), NotificationView.class);
// Send data to NotificationView Class
intent.putExtra("title", strtitle);
intent.putExtra("text", strtext);
// Open NotificationView.java Activity
PendingIntent pIntent = PendingIntent.getActivity(getContext(), 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
//Create Notification using NotificationCompat.Builder
NotificationCompat.Builder builder = new NotificationCompat.Builder(getContext())
// Set Icon
.setSmallIcon(R.drawable.icon)
// Set Ticker Message
.setTicker(getString(R.string.notificationticker))
// Set Title
.setContentTitle(getString(R.string.notificationtitle))
// Set Text
.setContentText(getString(R.string.notificationtext))
// Add an Action Button below Notification
.addAction(R.drawable.ic_audiotrack, "Action Button", pIntent)
// Set PendingIntent into Notification
.setContentIntent(pIntent)
// Dismiss Notification
.setAutoCancel(true);
// Create Notification Manager
// Create Notification Manager
NotificationManager notificationmanager = (NotificationManager) getContext().getSystemService(NOTIFICATION_SERVICE);
// Build Notification with Notification Manager
notificationmanager.notify(0, builder.build());
}
这是我的 noficationview.class
package com.Weal.sachin.omcom;
/**
* Created by sachin on 1/23/2017.
*/
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class NotificationView extends Activity {
String title;
String text;
TextView txttitle;
TextView txttext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.notificationview);
// Create Notification Manager
NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Dismiss Notification
notificationmanager.cancel(0);
// Retrive the data from MainActivity.java
Intent i = getIntent();
title = i.getStringExtra("title");
text = i.getStringExtra("text");
// Locate the TextView
txttitle = (TextView) findViewById(R.id.title);
txttext = (TextView) findViewById(R.id.text);
// Set the data into TextView
txttitle.setText(title);
txttext.setText(text);
}
}
我试过这种方式,这段代码没有在Button Click ...
上显示通知答案 0 :(得分:2)
可能是因为您正在尝试添加
Android NDK: NDK installation path auto-detected: 'E:/Android/AndroidSDK/SDK/ndk-bundle/build//..'
Android NDK: GNU Make version 3.81 detected
Android NDK: Host OS was auto-detected: windows
Android NDK: Host operating system detected: windows
'C:\Users\R' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the path specified.
Android NDK: Host CPU was auto-detected: x86
Android NDK: HOST_TAG set to windows
Android NDK: Host tools prebuilt directory: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin
Android NDK: Host 'echo' tool: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin/echo.exe
Android NDK: Host 'echo -n' tool: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin/echo.exe -n
Android NDK: Host 'cmp' tool: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin/cmp.exe
Android NDK: Host 'awk' tool: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin/awk.exe
Android NDK: Host 'awk' test returned: Pass
Android NDK: Found platform root directory: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms
Android NDK: Found supported platforms: android-12 android-13 android-14 android-15 android-16 android-17 android-18 android-19 android-21 android-22 android-23 android-2
4 android-9
Android NDK: PLATFORM android-12 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-12/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-12/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-12/arch-x86
Android NDK: PLATFORM android-13 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-13/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-13/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-13/arch-x86
Android NDK: PLATFORM android-14 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-14/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-14/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-14/arch-x86
Android NDK: PLATFORM android-15 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-15/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-15/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-15/arch-x86
Android NDK: PLATFORM android-16 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-16/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-16/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-16/arch-x86
Android NDK: PLATFORM android-17 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-17/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-17/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-17/arch-x86
Android NDK: PLATFORM android-18 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-18/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-18/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-18/arch-x86
Android NDK: PLATFORM android-19 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-19/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-19/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-19/arch-x86
Android NDK: PLATFORM android-21 supports: arm arm64 mips mips64 x86 x86_64
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-arm
Android NDK: ABI arm64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-arm64
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-mips
Android NDK: ABI mips64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-mips64
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-x86
Android NDK: ABI x86_64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-x86_64
Android NDK: PLATFORM android-22 supports: arm arm64 mips mips64 x86 x86_64
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-arm
Android NDK: ABI arm64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-arm64
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-mips
Android NDK: ABI mips64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-mips64
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-x86
Android NDK: ABI x86_64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-x86_64
Android NDK: PLATFORM android-23 supports: arm arm64 mips mips64 x86 x86_64
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-arm
Android NDK: ABI arm64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-arm64
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-mips
Android NDK: ABI mips64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-mips64
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-x86
Android NDK: ABI x86_64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-x86_64
Android NDK: PLATFORM android-24 supports: arm arm64 mips mips64 x86 x86_64
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-arm
Android NDK: ABI arm64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-arm64
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-mips
Android NDK: ABI mips64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-mips64
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-x86
Android NDK: ABI x86_64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-x86_64
Android NDK: PLATFORM android-9 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-9/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-9/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-9/arch-x86
Android NDK: Found stable platform levels: 12 13 14 15 16 17 18 19 21 22 23 24 9
Android NDK: Found max platform level: 24
Android NDK: This NDK supports the following target architectures and ABIS:
Android NDK: arm: armeabi armeabi-v7a
Android NDK: arm64: arm64-v8a
Android NDK: mips: mips
Android NDK: mips64: mips64
Android NDK: x86: x86
Android NDK: x86_64: x86_64
Android NDK: This NDK supports the following toolchains and target ABIs:
Android NDK: aarch64-linux-android-4.9: arm64-v8a
Android NDK: aarch64-linux-android-clang: arm64-v8a
Android NDK: arm-linux-androideabi-4.9: armeabi armeabi-v7a
Android NDK: arm-linux-androideabi-clang: armeabi armeabi-v7a
Android NDK: mips64el-linux-android-4.9: mips64
Android NDK: mips64el-linux-android-clang: mips64
Android NDK: mipsel-linux-android-4.9: mips
Android NDK: mipsel-linux-android-clang: mips
Android NDK: x86-4.9: x86
Android NDK: x86-clang: x86
Android NDK: x86_64-4.9: x86_64
Android NDK: x86_64-clang: x86_64
Android NDK: Make no attempt to look for NDK_PROJECT_PATH.
Android NDK: Ouput path for intermediate files: E:/Android/Aditya/poc/ObjectRecognition/app/build/intermediates/ndkBuild/debug/obj
Android NDK: Ouput path for generated library files: E:\Android\Aditya\poc\ObjectRecognition\app\build\intermediates\ndkBuild\debug\lib
Android NDK: Parsing E:\Android\Aditya\poc\ObjectRecognition\app\src\main\jni\Application.mk
Android NDK: APP_PIE is
Android NDK: Enabling -fPIE
Android NDK: Using build script E:\Android\Aditya\poc\ObjectRecognition\app\src\main\jni\Android.mk
Android NDK: Application 'local' is not debuggable
Android NDK: Selecting release optimization mode (app is not debuggable)
Android NDK: Adding import directory: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../sources
Android NDK: Building application 'local' for ABI 'armeabi'
Android NDK: Enabling -fPIE for TARGET_PLATFORM android-19
Android NDK: Using target toolchain 'arm-linux-androideabi-clang' for 'armeabi' ABI (through NDK_TOOLCHAIN_VERSION)
Android NDK: Looking for imported module with tag 'cxx-stl/gnu-libstdc++'
Android NDK: Probing E:/Android/AndroidSDK/SDK/ndk-bundle/build//../sources/cxx-stl/gnu-libstdc++/Android.mk
Android NDK: Found in E:/Android/AndroidSDK/SDK/ndk-bundle/build//../sources/cxx-stl/gnu-libstdc++
Android NDK: Module 'ObjectRecognition' has C++ sources
Android NDK: Add dependency 'gnustl_static' to module 'ObjectRecognition'
Android NDK: WARNING:E:\Android\Aditya\poc\ObjectRecognition\app\src\main\jni\Android.mk:ObjectRecognition: non-system libraries in linker flags: -lopencv_java
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: [armeabi] Modules to build: ObjectRecognition
'C:\Users\R' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the path specified.
make: *** [E:/Android/Aditya/poc/ObjectRecognition/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs/ObjectRecognition] Error 1
E:\Android\Aditya\poc\ObjectRecognition>ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=E:\Android\Aditya\poc\ObjectRecognition\app\src\main\jni\Android.mk NDK
_APPLICATION_MK=E:\Android\Aditya\poc\ObjectRecognition\app\src\main\jni\Application.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDEBUG=1 APP_PLATFORM=android-19 NDK_OUT
=E:/Android/Aditya/poc/ObjectRecognition/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=E:\Android\Aditya\poc\ObjectRecognition\app\build\intermediates
\ndkBuild\debug\lib clean NDK_LOG=1
Android NDK: NDK installation path auto-detected: 'E:/Android/AndroidSDK/SDK/ndk-bundle/build//..'
Android NDK: GNU Make version 3.81 detected
Android NDK: Host OS was auto-detected: windows
Android NDK: Host operating system detected: windows
'C:\Users\R' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the path specified.
Android NDK: Host CPU was auto-detected: x86
Android NDK: HOST_TAG set to windows
Android NDK: Host tools prebuilt directory: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin
Android NDK: Host 'echo' tool: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin/echo.exe
Android NDK: Host 'echo -n' tool: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin/echo.exe -n
Android NDK: Host 'cmp' tool: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin/cmp.exe
Android NDK: Host 'awk' tool: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../prebuilt/windows-x86_64/bin/awk.exe
Android NDK: Host 'awk' test returned: Pass
Android NDK: Found platform root directory: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms
Android NDK: Found supported platforms: android-12 android-13 android-14 android-15 android-16 android-17 android-18 android-19 android-21 android-22 android-23 android-2
4 android-9
Android NDK: PLATFORM android-12 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-12/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-12/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-12/arch-x86
Android NDK: PLATFORM android-13 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-13/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-13/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-13/arch-x86
Android NDK: PLATFORM android-14 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-14/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-14/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-14/arch-x86
Android NDK: PLATFORM android-15 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-15/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-15/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-15/arch-x86
Android NDK: PLATFORM android-16 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-16/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-16/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-16/arch-x86
Android NDK: PLATFORM android-17 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-17/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-17/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-17/arch-x86
Android NDK: PLATFORM android-18 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-18/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-18/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-18/arch-x86
Android NDK: PLATFORM android-19 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-19/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-19/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-19/arch-x86
Android NDK: PLATFORM android-21 supports: arm arm64 mips mips64 x86 x86_64
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-arm
Android NDK: ABI arm64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-arm64
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-mips
Android NDK: ABI mips64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-mips64
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-x86
Android NDK: ABI x86_64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-21/arch-x86_64
Android NDK: PLATFORM android-22 supports: arm arm64 mips mips64 x86 x86_64
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-arm
Android NDK: ABI arm64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-arm64
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-mips
Android NDK: ABI mips64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-mips64
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-x86
Android NDK: ABI x86_64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-22/arch-x86_64
Android NDK: PLATFORM android-23 supports: arm arm64 mips mips64 x86 x86_64
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-arm
Android NDK: ABI arm64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-arm64
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-mips
Android NDK: ABI mips64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-mips64
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-x86
Android NDK: ABI x86_64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-23/arch-x86_64
Android NDK: PLATFORM android-24 supports: arm arm64 mips mips64 x86 x86_64
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-arm
Android NDK: ABI arm64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-arm64
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-mips
Android NDK: ABI mips64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-mips64
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-x86
Android NDK: ABI x86_64 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-24/arch-x86_64
Android NDK: PLATFORM android-9 supports: arm mips x86
Android NDK: ABI arm sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-9/arch-arm
Android NDK: ABI mips sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-9/arch-mips
Android NDK: ABI x86 sysroot is: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../platforms/android-9/arch-x86
Android NDK: Found stable platform levels: 12 13 14 15 16 17 18 19 21 22 23 24 9
Android NDK: Found max platform level: 24
Android NDK: This NDK supports the following target architectures and ABIS:
Android NDK: arm: armeabi armeabi-v7a
Android NDK: arm64: arm64-v8a
Android NDK: mips: mips
Android NDK: mips64: mips64
Android NDK: x86: x86
Android NDK: x86_64: x86_64
Android NDK: This NDK supports the following toolchains and target ABIs:
Android NDK: aarch64-linux-android-4.9: arm64-v8a
Android NDK: aarch64-linux-android-clang: arm64-v8a
Android NDK: arm-linux-androideabi-4.9: armeabi armeabi-v7a
Android NDK: arm-linux-androideabi-clang: armeabi armeabi-v7a
Android NDK: mips64el-linux-android-4.9: mips64
Android NDK: mips64el-linux-android-clang: mips64
Android NDK: mipsel-linux-android-4.9: mips
Android NDK: mipsel-linux-android-clang: mips
Android NDK: x86-4.9: x86
Android NDK: x86-clang: x86
Android NDK: x86_64-4.9: x86_64
Android NDK: x86_64-clang: x86_64
Android NDK: Make no attempt to look for NDK_PROJECT_PATH.
Android NDK: Ouput path for intermediate files: E:/Android/Aditya/poc/ObjectRecognition/app/build/intermediates/ndkBuild/debug/obj
Android NDK: Ouput path for generated library files: E:\Android\Aditya\poc\ObjectRecognition\app\build\intermediates\ndkBuild\debug\lib
Android NDK: Parsing E:\Android\Aditya\poc\ObjectRecognition\app\src\main\jni\Application.mk
Android NDK: APP_PIE is
Android NDK: Enabling -fPIE
Android NDK: Using build script E:\Android\Aditya\poc\ObjectRecognition\app\src\main\jni\Android.mk
Android NDK: Application 'local' is not debuggable
Android NDK: Selecting release optimization mode (app is not debuggable)
Android NDK: Adding import directory: E:/Android/AndroidSDK/SDK/ndk-bundle/build//../sources
Android NDK: Building application 'local' for ABI 'armeabi'
Android NDK: Enabling -fPIE for TARGET_PLATFORM android-19
Android NDK: Using target toolchain 'arm-linux-androideabi-clang' for 'armeabi' ABI (through NDK_TOOLCHAIN_VERSION)
Android NDK: Looking for imported module with tag 'cxx-stl/gnu-libstdc++'
Android NDK: Probing E:/Android/AndroidSDK/SDK/ndk-bundle/build//../sources/cxx-stl/gnu-libstdc++/Android.mk
Android NDK: Found in E:/Android/AndroidSDK/SDK/ndk-bundle/build//../sources/cxx-stl/gnu-libstdc++
Android NDK: Module 'ObjectRecognition' has C++ sources
Android NDK: Add dependency 'gnustl_static' to module 'ObjectRecognition'
Android NDK: WARNING:E:\Android\Aditya\poc\ObjectRecognition\app\src\main\jni\Android.mk:ObjectRecognition: non-system libraries in linker flags: -lopencv_java
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
Android NDK: [armeabi] Modules to build: ObjectRecognition
'C:\Users\R' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the path specified.
make: *** [clean-ObjectRecognition-armeabi] Error 1
你片段的onClick()内部。由于您已经在onClick()中,因此不需要taskadd.setOnClickListener()。 而是用这个替换你的onClick()方法。
taskadd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addtask=taskname.getText().toString();
adddetail=taskdetail.getText().toString();
adddate= taskdate.getText().toString();
InsertData();
Notification();
}
});
答案 1 :(得分:0)
尝试使用此代码生成小型和大型通知
完整源代码source
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), PushNotificationDemo.class);
final PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
NotificationManager notificationManager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Notification n;
switch (v.getId()) {
case R.id.nd_smallnotification:
if (heading.getText().length() <= 0) {
heading.setError("Please provide push notification title");
} else {
heading.setError(null);
heading_text = heading.getText().toString();
n = new NotificationCompat.Builder(this)
.setContentTitle(heading_text)
.setContentText(message.getText().toString())
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pending)
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true)
.setWhen(System.currentTimeMillis())
.addAction(android.R.drawable.ic_menu_manage, "Close", pending)
.build();
n.flags |= Notification.FLAG_AUTO_CANCEL | Intent.FLAG_ACTIVITY_SINGLE_TOP;
notificationManager.notify(0, n);
}
break;
case R.id.nd_bignotification:
if (heading.getText().length() <= 0) {
heading.setError("Please provide push notification title");
} else {
heading.setError(null);
heading_text = heading.getText().toString();
NotificationCompat.InboxStyle nc =
new NotificationCompat.InboxStyle();
nc.setBigContentTitle(heading_text);
String[] text = new String[5];
for (int i = 0; i < 5; i++) {
text[i] = i + ". say hello...";
nc.addLine(text[i]);
}
n = new NotificationCompat.Builder(this)
.setStyle(nc)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pending)
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true)
.setWhen(System.currentTimeMillis())
.build();
n.flags |= Notification.FLAG_AUTO_CANCEL | Intent.FLAG_ACTIVITY_SINGLE_TOP;
notificationManager.notify(100, n);
}
break;
}
}
答案 2 :(得分:0)
初始化。 onClick
onCreate()
内的taskname = (EditText) view.findViewById(R.id.taskname);
taskdetail = (EditText) view.findViewById(R.id.taskdetail);
taskdate = (EditText) view.findViewById(R.id.taskdate);
taskadd = (Button) view.findViewById(R.id.taskaddtask);
taskadd.setOnClickListener(getActivity); //<----here
:
onClick
正确使用public void onClick(View view) {
if(view == taskadd) {
fromDatePickerDialog.show(); //use this properly
addtask=taskname.getText().toString();
adddetail=taskdetail.getText().toString();
adddate= taskdate.getText().toString();
InsertData();
Notification();
}
}
,不要初始化。视图两次:
context
同时获取fragment
的{{1}}。从getContext()
移除Notification
:
删除它:
getContext();
有了这个:
getActivity();