मुझे पता है, यहां पर बहुत से लोग हैं, लेकिन मैं पूरे दिन समाधान का प्रयास कर रहा हूं और कहीं भी नहीं मिला हूं। न तो Google के दस्तावेज़ों पर उदाहरण, न ही मैंने यहां पाए गए 5 अन्य तरीकों में से कोई भी मेरे लिए काम किया है। सामान्य मामला है, जब मैं अधिसूचना पर क्लिक करता हूं तो यह स्टेटस बार बंद कर देता है और कुछ भी नया स्क्रीन पर नहीं दिखाया जाता है। मैं एक सेवा से अधिसूचना बना रहा हूं और एक नई गतिविधि को ट्रिगर करने के लिए अधिसूचना की आवश्यकता है जो अभी तक नहीं बनाई गई है। मुझे इरादे के माध्यम से उस गतिविधि को जानकारी पास करने के लिए भी एक तरीका चाहिए।अधिसूचना पर क्लिक होने पर सेवा से लॉन्च गतिविधि
और हाँ ... इस Android
क्या इस प्रकार मेरी कोड के टूटे अवशेष हैं के लिए जावा है।
package com.bobbb.hwk2;
import java.io.FileOutputStream;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.IBinder;
import android.provider.ContactsContract;
import android.widget.Toast;
public class contactBackup extends Service
{
private NotificationManager nManager;
private static final int NOTIFY_ID = 1100;
@Override
public void onCreate()
{
super.onCreate();
String ns = Context.NOTIFICATION_SERVICE;
nManager = (NotificationManager)getSystemService(ns);
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
// inform user that service has started
Toast.makeText(getApplicationContext(), R.string.service_started,Toast.LENGTH_LONG).show();
String data = lookUpContacts();
if(saveToSDCard(getResources().getString(R.string.backup_file_name),data))
{
Context context = getApplicationContext();
// create the statusbar notification
Intent nIntent = new Intent(this,contactViewer.class);//Intent nIntent = new Intent(Intent.ACTION_MAIN);
nIntent.setClass(context,contactViewer.class);
//nIntent.putExtra("data",data);
Notification msg = new Notification(R.drawable.icon,"All contacts records have been written to the file.",System.currentTimeMillis());
// start notification
//PendingIntent pIntent = PendingIntent.getService(getApplicationContext(),0,nIntent,PendingIntent.FLAG_UPDATE_CURRENT|Intent.FLAG_FROM_BACKGROUND);
PendingIntent pIntent = PendingIntent.getActivity(this,0,nIntent,0);
msg.flags = Notification.FLAG_AUTO_CANCEL;
msg.setLatestEventInfo(context,
"success",
"All contacts records have been written to the file.",
pIntent);
nManager.notify(NOTIFY_ID,msg);
}
}
@Override
public void onDestroy()
{
nManager.cancel(NOTIFY_ID);
super.onDestroy();
}
@Override
public IBinder onBind(Intent intent)
{
return null;
}
// function returns string containing information
// from contacts
public String lookUpContacts()
{
...
}
public boolean saveToSDCard(String fileName, String data)
{
...
}
}
मैं केवल आशा कर सकते हैं कि जो कुछ भी मेरी समस्या का कारण है कुछ सुधारी जा सकने वाली और पागल खामियों मैं ग्रहण के साथ हो रही किया गया है की नहीं अधिक है (और कोई नहीं लगता है जो कभी देखा है करने के लिए>: यू)
यदि आप इस समस्या को हल करने में मेरी मदद कर सकते हैं, तो कृपया साझा करें। नहीं आप इस विशिष्ट समस्या के साथ मदद नहीं कर सकता लेकिन पोस्टिंग, शैली, विषय या अच्छा अभ्यास के बारे में असंबंधित बातें कहने के लिए बाध्य लग रहा है, तो
धन्यवाद: डी
अच्छी तरह से , यह वास्तव में नहीं है कि आप putExtra का उपयोग कैसे करते हैं ... लेकिन आपकी सलाह के आधार पर मैंने एडीआई की कोशिश की एनजी जो दोनों इरादे और लंबित इंटेंटेंट को ध्वजांकित करता है और न ही कोई फर्क पड़ता है। हालांकि धन्यवाद। – user980058
आपके संपादन से मेल खाता है जो मैंने किया था। अभी भी कोई पासा नहीं: 3 – user980058