onReceive does not called after download completed - android

I'm trying to use android downloadManager via this tutorial . I move broadCastReciever block in a single function, and below is my code:
public void downloadManager(){
boolean is_downloaded = false;
Log.e("error ", "1");
receiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
Log.e("error ", "2");
String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
Log.e("error ", "3");
DownloadManager.Query query = new DownloadManager.Query();
query.setFilterById(enqueue);
Cursor c = dm.query(query);
Log.e("error ", "4");
if (c.moveToFirst()) {
Log.e("error ", "5");
int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) {
// download finished successfully
is_downloaded = true;
Log.e("error ", "6");
}
}
}
}
};
getActivity().registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
when I run the project, is_downloaded will remains false. and in logcat I can see just this line:
error: 1
means that the application control will never reach other Logs so
#Override
public void onReceive(Context context, Intent intent)
will never call. but the image downloads successfully. every thing seems OK, where is the problem?

Try to use
<uses-permission android:name="android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS" />
of course, do not forget this:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
if doesn't help try to use BroadcastListener
public class DownloadListenerService extends BroadcastReceiver {
#Override
public void onReceive(final Context context, Intent intent) {
System.out.println("got here");
///// your code here
}
}
}
`
<receiver
android:name="com.example.DownloadListenerService"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.INTERNET" />
`
Part of code is from here:
https://stackoverflow.com/a/18789470/1979882

try it through AsyncTask, keep isDownloaded false in onPreExecute() then download the content in doInBackground() and then assign true to isDownloaded in onPostExecute().

Related

FileObserver does not triggering events while invoking in background service

There are answered questions regarding FileObserver in Android and I am following them but still my code doesn't work. Here I am posting my code, I am trying to set fileObserver via service so it work even if the app itself is closed. When running, it is invoking the DirectoryObserver Constructor but adding or deleting a file doesn't invoke the event
public class MainActivity extends AppCompatActivity
{
private String sharedPreferencesKey = "IsThisFIrstTime";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
if (!preferences.contains(sharedPreferencesKey)) {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(sharedPreferencesKey, false);
editor.apply();
try {
startTheServices();
}
catch (Exception ex) {
}
}
setContentView(R.layout.activity_main);
}
private void startTheServices()
{
Intent intent = new Intent(this, BackgroundServices.class);
startService(intent);
}
}
public class BackgroundServices extends Service {
#Override
public void onCreate(){
super.onCreate();
Toast.makeText(this, "This is on Create", Toast.LENGTH_LONG).show();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
Toast.makeText(this, "This is on onStartCommand", Toast.LENGTH_LONG).show();
Thread thread = new Thread(new ThreadClass(startId));
thread.start();
return super.onStartCommand(intent, flags, startId);
//return START_STICKY;
}
#Override
public void onDestroy(){
super.onDestroy();
}
#Nullable
#Override
public IBinder onBind(Intent intent) {
return null;
}
final class ThreadClass implements Runnable {
int _serviceId;
ThreadClass(int serviceId) {
_serviceId = serviceId;
}
#Override
public void run() {
DirectoryObserver directoryObserver = new DirectoryObserver(new File(Environment.getExternalStorageDirectory(), Constants.Camera_Directory).getAbsolutePath(), getApplicationContext());
directoryObserver.startWatching();
}
}
}
public class DirectoryObserver extends FileObserver {
private static final String TAG = "DIRECTORY_OBERSVER";
private String directoryPath;
private Context _context;
public DirectoryObserver(String path, Context context) {
super(path);
Log.i(TAG, "Something Happening " + path);
_context = context;
directoryPath = path;
}
#Override
public void onEvent(int event, #Nullable String path) {
if (path == null) {
return;
}
//a new file or subdirectory was created under the monitored directory
if ((FileObserver.CREATE & event)!=0) {
Log.i(TAG, "A file is added to the path " + path);
Toast.makeText(_context, "A new file has been added", Toast.LENGTH_LONG).show();
}
if ((FileObserver.DELETE & event)!=0) {
Log.i(TAG, "A file is deleted to the path " + path);
//Context.getApplicationContext();
}
}
}
And following is the menifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="someone.package">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".BackgroundServices" android:exported="false"></service>
</application>
</manifest>
Have You Added The Permission? I Don't Have Enough Reps Otherwise I Would have Commented.
The problem here is that the FileObserver is probably being garbage collected, as you can see here:
Warning: If a FileObserver is garbage collected, it will stop sending events. To ensure you keep receiving events, you must keep a reference to the FileObserver instance from some other live object.
Android might be getting rid of your service, or even the FileObserver itself. Try to see if the code is entering the "startWatching()" method, or even if the service is starting.
The solution I found is that move the following initialization of DirectoryObserver
DirectoryObserver directoryObserver = new DirectoryObserver(new File(Environment.getExternalStorageDirectory(), Constants.Camera_Directory).getAbsolutePath(), getApplicationContext());
to
public int onStartCommand(Intent intent, int flags, int startId)
method in BackgroundService Class before following lines
Thread thread = new Thread(new ThreadClass(startId));
thread.start();

Application getting hanged when try to call camera class multiple times through service

I am trying to capture images through camera in background service but while doing this my application is getting hanged and some times it gives me error of " Fail to connect to camera service" Although my images are getting store after every 20 seconds by my app ui either get hanged or it crashes.
Please have a look on my service class :-
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
captureImage();
}
private void captureImage() {
int count = 0;
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (IS_ACTIVITY_FINISHED) {
count++;
if (count == 20) {
// Start Activity here
Intent translucent = new Intent(getApplicationContext(),
HiddenCamera.class);
translucent.putExtra("FLASH", "off");
translucent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(translucent);
IS_ACTIVITY_FINISHED = false;
break;
}
}
}
}
#Override
public IBinder onBind(Intent intent) {
return null;
}
here is my HiddenCamera class :-
http://piratepad.net/ep/pad/view/ro.LgLDgdzewfJ/latest
my Manifest file :-
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<service android:name="com.example.services.CameraService" >
</service>
Please provide me any useful information regarding this process.
Thanks
Finally i am able to solve it :-
here is my service class code :-
private void startCapturingImage() {
Toast.makeText(getApplicationContext(), "InSide service class", 1000)
.show();
mDownTimer = new CountDownTimer(20000, 1000) {
#SuppressWarnings("deprecation")
#Override
public void onFinish() {
// count finished
if (IS_ACTIVITY_FINISHED) {
Toast.makeText(getApplicationContext(), "InSide on finished method class", 1000)
.show();
IS_ACTIVITY_FINISHED = false;
Intent translucent = new Intent(getApplicationContext(),
HiddenCamera.class);
translucent.putExtra("FLASH", "off");
translucent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(translucent);
mDownTimer.start();
}else{
startCapturingImage();
}
}
#Override
public void onTick(long millisUntilFinished) {
}
}.start();

Why onPushMessageReceived() is not called in Geoloqi API in Android?

In my android app i am using Latest Geoloqi API to implement Geofence concept.when user entered into some region he has notify, for that purpose i am using Push Notifications.in GeoReceiver class three callback methods are calling but not onPushMessageReceived().please help me how to do it?
I am creating trigger with current location is it required to enter into region manually or since i am already in the location its not calling?
Note:I ve given required credentials in assets/geoloqi.properties file.when app is launched in logcat "Successfully registered for the C2DM service" msg also displayed.my code:
GeoloqiExampleActivity.java
public class GeoloqiExampleActivity extends Activity{
String TAG = "Geoloqi Example";
private LQService mService;
private boolean mBound;
GeoReceiver geoReceiver = new GeoReceiver();
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(this, LQService.class);
startService(intent);
}
#Override
public void onResume() {
super.onResume();
// Bind to the tracking service so we can call public methods on it
Intent intent = new Intent(this, LQService.class);
bindService(intent, mConnection, 0);
// Wire up the sample location receiver
final IntentFilter filter = new IntentFilter();
filter.addAction(GeoReceiver.ACTION_LOCATION_CHANGED);
filter.addAction(GeoReceiver.ACTION_TRACKER_PROFILE_CHANGED);
filter.addAction(GeoReceiver.ACTION_LOCATION_UPLOADED);
filter.addAction(GeoReceiver.ACTION_PUSH_MESSAGE_RECEIVED);
registerReceiver(geoReceiver, filter);
}
#Override
public void onPause() {
super.onPause();
// Unbind from LQService
if (mBound) {
unbindService(mConnection);
mBound = false;
}
// Unregister our location receiver
unregisterReceiver(geoReceiver);
}
public void sendRequest() {
// Performing a Trigger POST request
if (mService != null) {
LQSession session = mService.getSession();
LQTracker tracker = mService.getTracker();
tracker.setSession(session);
// Build your request
JSONObject trigger = new JSONObject();
try {
trigger.put("text", "Popcornapps");
trigger.put("type", "message");
trigger.put("latitude", 17.42557068);
trigger.put("longitude", 78.42022822);
trigger.put("radius", 500);
trigger.put("place_name", "Banjara Hills");
} catch (JSONException e) {
Log.d(TAG, e.getMessage());
}
// Send the request
session.runPostRequest("trigger/create", trigger, new OnRunApiRequestListener() {
#Override
public void onSuccess(LQSession session, HttpResponse response) {
Toast.makeText(GeoloqiExampleActivity.this, "Success", Toast.LENGTH_SHORT).show();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder s = new StringBuilder();
String sResponse;
while ((sResponse = reader.readLine()) != null) {
s = s.append(sResponse);
}
String result = s.toString().trim();
Log.d("On success Result", result);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
#Override
public void onFailure(LQSession session, LQException e) {
Log.e(TAG, e.getMessage());
Toast.makeText(GeoloqiExampleActivity.this, "Fail", Toast.LENGTH_LONG).show();
}
#Override
public void onComplete(LQSession session, HttpResponse response, StatusLine status) {
Toast.makeText(GeoloqiExampleActivity.this, "Complete", Toast.LENGTH_LONG).show();
}
});
} else{
Toast.makeText(this, "service null", Toast.LENGTH_LONG).show();
}
}
/** Defines callbacks for service binding, passed to bindService() */
private ServiceConnection mConnection = new ServiceConnection() {
#Override
public void onServiceConnected(ComponentName name, IBinder service) {
try {
// We've bound to LocalService, cast the IBinder and get LocalService instance.
LQBinder binder = (LQBinder) service;
mService = binder.getService();
mBound = true;
sendRequest();//Sending API Request
} catch (ClassCastException e) {
}
}
#Override
public void onServiceDisconnected(ComponentName name) {
mBound = false;
}
};
}
GeoReceiver.java
public class GeoReceiver extends LQBroadcastReceiver {
#Override
public void onLocationChanged(Context arg0, Location arg1) {
Toast.makeText(arg0, "Loc Changed ", Toast.LENGTH_SHORT).show();
}
#Override
public void onPushMessageReceived(Context context, Bundle data) {
Toast.makeText(context, "Push Msg Received ", Toast.LENGTH_LONG).show();
}
#Override
public void onLocationUploaded(Context arg0, int arg1) {
Toast.makeText(arg0, "Location Uploaded ", Toast.LENGTH_SHORT).show();
}
#Override
public void onTrackerProfileChanged(Context arg0, LQTrackerProfile oldp,
LQTrackerProfile newp) {
Toast.makeText(arg0, "onTrackerProfileChanged ",Toast.LENGTH_SHORT).show();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pop.geoloqi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<permission
android:name="com.pop.geoloqi.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.pop.geoloqi.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".GeoloqiExampleActivity"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="com.geoloqi.android.sdk.service.LQService"
android:exported="false" />
<receiver
android:name=".GeoReceiver"
android:enabled="false"
android:exported="false" >
<intent-filter>
<action android:name="com.geoloqi.android.sdk.action.LOCATION_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name="com.geoloqi.android.sdk.receiver.LQDeviceMessagingReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.pop.geoloqi" />
</intent-filter>
</receiver>
</application>
</manifest>
There was a bug in earlier versions of the Geoloqi Android SDK. If you update to the latest version this problem should be resolved.

Catch sent SMS (Android 2.2)

I know that there are a few Questions here on SO relating to this, but none of them helped me to get this working - capture SMS that being sent.
I am using Android 2.2 (FROYO) on a Samsung phone (if that matters somehow).
I've searched a lot for this on Stackoverflow and realized that I need ContentObserver for my request. I'm using Service instead of Activity, so I've registered that ContentObserver in my Service class, and it looks like this:
public class SMSSending extends Service {
private class MyContentObserver extends ContentObserver {
public MyContentObserver() {
super(null);
}
#Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
Uri uriSMSURI = Uri.parse("content://sms/sent");
Cursor cur = getBaseContext().getContentResolver().query(uriSMSURI, null, null, null, null);
cur.moveToNext();
String content = cur.getString(cur.getColumnIndex("body"));
Toast.makeText(getApplicationContext(), "SOME TEXT", Toast.LENGTH_LONG).show();
}
#Override
public boolean deliverSelfNotifications() {
return false;
}
}
#Override
public IBinder onBind(Intent intent) {
return null;
}
#Override
public void onCreate() {
MyContentObserver contentObserver = new MyContentObserver();
ContentResolver contentResolver = getBaseContext().getContentResolver();
contentResolver.registerContentObserver(Uri.parse("content://sms/sent"),true, contentObserver);
Toast.makeText(getApplicationContext(), "SERVICE CREATED", Toast.LENGTH_LONG).show();
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
#Override
public void onStart(Intent intent, int startid) {
Toast.makeText(getApplicationContext(), "SERVICE STARTED", Toast.LENGTH_LONG).show();
}
}
As you can see I've put Toast in few places so I could see if this is working at all - and unfortunately none of this notifications appear. Also, i tried with putting some code for LogCat but nothing happens.
I've also tried to put Uri uriSMSURI = Uri.parse("content://sms"); instead of content://sms/sent
but the application simply doesn't do anything.
Of course, I have permissions in Manifest:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
What am i missing?
Fortunately, I've managed to work it out, but by using totally different approach. Maybe is this going to help someone in future..
Instead of using ContentObserver (which I still don't know why didn't work) I've created new Thread and started it after my service has been created and started. So it looks like this:
...
final Uri CONTENT_URI = Uri.parse("content://sms/sent");
...
public void onStart(Intent intent, int startid) {
Go();
}
private void Go(){
new Thread(new Runnable() {
public void run() {
try {
while(true){
Cursor cursor = getContentResolver().query(CONTENT_URI, null, null, null, null);
if(cursor.moveToFirst()){
text = cursor.getString(cursor.getColumnIndexOrThrow("body")).toString();
if(!text.equalsIgnoreCase(actual)){
previous = text;
//do what you need..
}
}
Thread.sleep(60000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
It's working absolutely stable, even better than with using ContentObserver, having in mind that lot of people had problems with it, something like this and some other..

Log call information whenever there is a phone call

I have written the android application and I want the application to send the call information whenever there is an incoming call and it ends. This way I would be sending all calls to the server irrespective of size of the call log.
Here is the code
public class PhoneInfo extends BroadcastReceiver {
private int incoming_call = 0;
private Cursor c;
Context context;
public void onReceive(Context con, Intent intent) {
c = con.getContentResolver().query(
android.provider.CallLog.Calls.CONTENT_URI, null, null, null,
android.provider.CallLog.Calls.DATE + " DESC");
context = con;
IncomingCallListener phoneListener = new IncomingCallListener();
TelephonyManager telephony = (TelephonyManager) con
.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
public class IncomingCallListener extends PhoneStateListener {
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
if (incoming_call == 1) {
CollectSendCallInfo();
incoming_call = 0;
}
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
break;
case TelephonyManager.CALL_STATE_RINGING:
incoming_call = 1;
break;
}
}
private void CollectSendCallInfo() {
int numberColumn = c
.getColumnIndex(android.provider.CallLog.Calls.NUMBER);
int dateColumn = c.getColumnIndex(android.provider.CallLog.Calls.DATE);
int typeColumn = c.getColumnIndex(android.provider.CallLog.Calls.TYPE);
int durationColumn = c
.getColumnIndex(android.provider.CallLog.Calls.DURATION);
ArrayList<String> callList = new ArrayList<String>();
try {
boolean moveToFirst = c.moveToFirst();
}
catch (Exception e) {
; // could not move to the first row.
return;
}
int row_count = c.getCount();
int loop_index = 0;
int is_latest_call_read = 0;
String callerPhonenumber = c.getString(numberColumn);
int callDate = c.getInt(dateColumn);
int callType = c.getInt(typeColumn);
int duration = c.getInt(durationColumn);
while ((loop_index < row_count) && (is_latest_call_read != 1)) {
switch (callType) {
case android.provider.CallLog.Calls.INCOMING_TYPE:
is_latest_call_read = 1;
break;
case android.provider.CallLog.Calls.MISSED_TYPE:
break;
case android.provider.CallLog.Calls.OUTGOING_TYPE:
break;
}
loop_index++;
c.moveToNext();
}
SendCallInfo(callerPhonenumber, Integer.toString(duration),
Integer.toString(callDate));
}
private void SendCallInfo(String callerPhonenumber, String callDuration,
String callDate) {
JSONObject j = new JSONObject();
try {
j.put("Caller", callerPhonenumber);
j.put("Duration", callDuration);
j.put("CallDate", callDate);
} catch (JSONException e) {
Toast.makeText(context, "Json object failure!", Toast.LENGTH_LONG)
.show();
}
String url = "http://xxxxxx.xxx.xx/xxxx/xxx.php";
Map<String, String> kvPairs = new HashMap<String, String>();
kvPairs.put("phonecall", j.toString());
HttpResponse re;
try {
re = doPost(url, kvPairs);
String temp;
try {
temp = EntityUtils.toString(re.getEntity());
if (temp.compareTo("SUCCESS") == 0) {
;
}
else
;
} catch (ParseException e1) {
Toast.makeText(context, "Parse Exception in response!",
Toast.LENGTH_LONG).show();
e1.printStackTrace();
} catch (IOException e1) {
Toast.makeText(context, "Io exception in response!",
Toast.LENGTH_LONG).show();
e1.printStackTrace();
}
} catch (ClientProtocolException e1) {
Toast.makeText(context, "Client Protocol Exception!",
Toast.LENGTH_LONG).show();
e1.printStackTrace();
} catch (IOException e1) {
Toast.makeText(context, "Client Protocol Io exception!",
Toast.LENGTH_LONG).show();
e1.printStackTrace();
}
}
}
and here is the manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Friend" android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
<uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER"></uses-permission>
<uses-permission android:name="android.permission.SET_DEBUG_APP"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".Friend" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginInfo" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
</intent-filter>
</activity>
<service android:exported="true" android:enabled="true"
android:name=".GeoUpdateService">
</service>
<receiver android:name=".SmsInfo">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<receiver android:name=".PhoneInfo">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"></action>
</intent-filter>
</receiver>
</application>
</manifest>
The application just crashes when there is an incoming call. I have been able to log the information about incoming SMS, but this call info logging is failing.
In my opinion you use BroadcastReciver in wrong way. You perform sync-query which can last more time than you have for handling broadcast. Next issue - you register listener object which will be probably collected by GC just after the end of onReceive method. Your BroadR should start service for handling those events.

Categories

Resources