[Q] Multiple Alarms - General Questions and Answers

Hi ,
I am looking for someone to assist me with a problem that i have with multiple alerts .
i have created pending intents with different requestCode but i do not know how to catch this code in my broadcast handler
here is the relevant code :
Intent intent = new Intent(PROXIMITY_ALERT);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 123, intent , PendingIntent.FLAG_CANCEL_CURRENT);
lm.addProximityAlert(30.28006245, 31.85403462, 200, -1, pendingIntent);
thanks !

Related

[Q] V.BASIC 2008 - WINDOWS MOBILE SMS RECEIVE TROUBLE - HTC phone

Hallo to XDA DEVELOPERS,
Please very much, I want ask for trouble, which I cant solve for many days.
I read many informations about receiving SMS, I tryed many examples of code and I build many codes which are from my head, but it not functioned.
Please, I have very big trouble. Many days I try develope application for receiving SMS, but I cant this.
I can send sms and use mobile and outlook functions, but I CANT RECEIVE SMS.
This is one of my code:
Imports Microsoft.WindowsMobile.PocketOutlook.MessageInterception
Imports Microsoft.WindowsMobile.Telephony
Imports Microsoft.WindowsMobile
Imports Microsoft.WindowsMobile.PocketOutlook
Imports System.Messaging
Imports System
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.WindowsMobile.Status
PublicClass Form1
Private _smsInterceptor As MessageInterceptor
PrivateSub Form1_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMyBase.Load
If MessageInterceptor.IsApplicationLauncherEnabled(_appId) Then
_smsInterceptor = New MessageInterceptor(_appId)
Else
_smsInterceptor = New MessageInterceptor(InterceptionAction.Notify)
_smsInterceptor.MessageCondition = New MessageCondition(MessageProperty.Body, _
MessagePropertyComparisonType.StartsWith, "www")
EndIf
AddHandler _smsInterceptor.MessageReceived, New MessageInterceptorEventHandler(AddressOf SmsInterceptor_MessageReceived)
Display("Event Wired")
EndSub
Sub Display(ByVal text AsString)
TextBox1.Text &= text & vbCrLf
EndSub
PrivateSub SmsInterceptor_MessageReceived(ByVal sender AsObject, ByVal e As MessageInterceptorEventArgs)
Display("Received")
Dim theMessage As SmsMessage = TryCast(e.Message, SmsMessage)
IfNot theMessage IsNothingThen
Display("Msg: " & theMessage.From.Address & " - " & theMessage.Body)
EndIf
EndSub
Const _appId AsString = "sms"
PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If MessageInterceptor.IsApplicationLauncherEnabled(_appId) Then
_smsInterceptor = New MessageInterceptor(_appId)
Else
_smsInterceptor = New MessageInterceptor(InterceptionAction.Notify)
_smsInterceptor.MessageCondition = New MessageCondition(MessageProperty.Body, _
MessagePropertyComparisonType.StartsWith, "www")
EndIf
AddHandler _smsInterceptor.MessageReceived, New MessageInterceptorEventHandler(AddressOf SmsInterceptor_MessageReceived)
EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
_smsInterceptor.EnableApplicationLauncher(_appId)
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
_smsInterceptor.DisableApplicationLauncher()
EndSub
EndClass
' ------------------------------------------------------------------------
But trouble is, that this:
AddHandler _smsInterceptor.MessageReceived, New MessageInterceptorEventHandler(AddressOf SmsInterceptor_MessageReceived)
I thing that this not see incomming message....and I dont know why.....???
When I see registers then in folder INBOX/RULES I see Rules which set this code, but when comes SMS then nothing is happen...
Idont know , what can I do, please very much, very,very, I need help, please for advice.
I have windows mobile 6.3
HTC mobile phone
All is functioned, but receiving sms I cant solve,
please very much for advice
Thank you and nice day

[Q] Error getting cellid

I am trying to get the cellid from a windows phone 7 program and the code I am using gives me an error when I call the RIL_Initialize function. The code it the standard c# that I have found in several places that everyone seems to be using.
When I try to run this code, I get an exception on the RIL_Initialize.
{"Attempt to access the method failed: CellInfo.RIL.RIL_Initialize(System.UInt32, CellInfo.RIL+RILRESULTCALLBACK, CellInfo.RIL+RILNOTIFYCALLBACK, System.UInt32, System.UInt32, System.IntPtr&)"}
Code:
public static string GetCellTowerInfo()
{
// initialise handles
IntPtr hRil = IntPtr.Zero;
IntPtr hRes = IntPtr.Zero;
// initialise result
celltowerinfo = "";
// initialise RIL
hRes = RIL_Initialize(1, // RIL port 1
new RILRESULTCALLBACK(rilResultCallback), // function to call with result
null, // function to call with notify
0, // classes of notification to enable
0, // RIL parameters
out hRil); // RIL handle returned
....etc.

[Resolved] [Q][DEV]Android Development Question about Shared Preferences.

Hi, I'm trying to do a simple login with Facebook in my app but I'm having trouble with Shared Preferences.
The idea is to start the app, it opens Activity A, checks if it's logged, and if it isn't, it sends you to activity B, you login and then go back to A.
My problem is that I can't get the SharedPreferences. I can save it, but I can't get it in the other activity.
So, it gets in a loop: A can't get the SP, so thinks it's not logged in, so send you to B, but B is logged on, and sends you to A...
That's my code in B:
Code:
public void onComplete(Bundle values) {
// TODO Auto-generated method stub
Editor edit = fbSP.edit();
edit.putString("access_token", fb.getAccessToken());
edit.putLong("access_expires", fb.getAccessExpires());
edit.commit();
aIMG();
ir();
}
And that's my code in A, where the problem is:
Code:
private SharedPreferences prefs;
public static String TOKEN = null;
public static final String FACEBOOK_DATA = "FacebookStuff";
long EXPIRES = 0;
...
private void SharedP() {
// TODO Auto-generated method stub
prefs = getSharedPreferences(FACEBOOK_DATA, MODE_PRIVATE);
TOKEN = prefs.getString("access_token", null);
EXPIRES = prefs.getLong("access_expires", 0);
if (TOKEN == null && EXPIRES == 0) { //If it's not logged in...
Intent login = new Intent("android.intent.action.FACELOGIN");
startActivity(login);
}
}
Edit: I got it. I was iniciating fbSP with getPreferences, not getSharedPreferences.

Application for notify when your flat is power-less

Hi everyone
I was searching one app for android, but i cannot find any like that.
Basically i need to understand when my flat went down on electricity
beacuse i have food in the fridge, fish in the acquarium or whatever you may have.
I was thinking i could leave a currently unused phone on charge in the wall socket.
When electricity goes off the phone stop charging and it can notify me with email.
Do you think something like that exist?
A general event driven notifier that support email would be fine.
Is there anything like that? on the market even a paid app?
Best regards, Andrea
You could try using Tasker for it.
"To err is human, to forgive is divine"
Sent from my SGS II
Tasker do half of the job...
it detects what i need, it compose the email...
but it cannot send it!!!
It can open a web url directly, so i can program a simple php script to send an email.
But if i could do without a webserver helping me it would be better.
I think that SMS notification will be more reliable in this case. Anyway all that you need is a very simple app, probably no more than several lines of code. If you are still interested in this I can help you to write one (if you have at least basic programming knowledge) or write one for you.
qubas said:
I think that SMS notification will be more reliable in this case. Anyway all that you need is a very simple app, probably no more than several lines of code. If you are still interested in this I can help you to write one (if you have at least basic programming knowledge) or write one for you.
Click to expand...
Click to collapse
solved with tasker. i make it open weburl, on web url i made application that send email.
cause tasker compose but cannot send.
i have programming knowledge,i would like to start,i just don t like java
maybe just a problem of mine
do you have some empty app franework to look at?
asturur said:
solved with tasker. i make it open weburl, on web url i made application that send email.
cause tasker compose but cannot send.
i have programming knowledge,i would like to start,i just don t like java
maybe just a problem of mine
do you have some empty app franework to look at?
Click to expand...
Click to collapse
There are many tutorials for installing Android Development Tools (ADT) and creating simple "Hello world" app. It probably takes 1 hour to do that. For simple app you don't really have to know Java, copy-paste some code samples from the Internet should do the trick, you just need to have at least some basic programming knowledge.
I still think that sending SMS is the most reliable solution. Using Wifi is a bad idea, because it won't work when there is no AC, unless you have a UPS. With 3G its much better, but still you have to rely on the web service you use to send email.
Anyway, here is my code:
Code:
package com.example.powermonitoring;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.telephony.SmsManager;
import android.widget.Toast;
public class MainActivity extends Activity {
private static final String NUMBER = "+48123456789";
private static final int THRESHOLD = 10;
private static final String AC_ONLINE = "AC is back online!";
private static final String AC_OFFLINE = "AC is offline!";
private Handler handler = new Handler();
private int counter;
private boolean lastPowerState;
private boolean powerState;
private Runnable runnable = new Runnable() {
[user=439709]@override[/user]
public void run() {
powerState = isPlugged(MainActivity.this);
if (powerState != lastPowerState) {
counter++;
if (counter == THRESHOLD) {
counter = 0;
lastPowerState = powerState;
String message;
if (powerState) {
message = AC_ONLINE;
} else {
message = AC_OFFLINE;
}
Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show(); //for testing
//SmsManager sms = SmsManager.getDefault();
//sms.sendTextMessage(NUMBER, null, message, null, null);
}
}
handler.postDelayed(this, 1000);
}
};
public static boolean isPlugged(Context context) {
Intent intent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
return plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB;
}
[user=439709]@override[/user]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lastPowerState = isPlugged(MainActivity.this);
handler.postDelayed(runnable, 1000);
}
}
You just have to remember about including permission in AndroidManifest.xml :
Code:
<uses-permission
android:name="android.permission.SEND_SMS"
/>

[Q] MX Player returns null in onActivityResult

My code is
Code:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setType("application/mp4");
intent.setData(uri);
intent.putExtra("position", 0);
intent.putExtra("return_result", true);
startActivityForResult(intent, PLAY_CODE);
Why onActivityResult method receives null in intent data?
Also onActivityResult always receives result code RESULT_CANCELED.
marievych said:
My code is
Code:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setType("application/mp4");
intent.setData(uri);
intent.putExtra("position", 0);
intent.putExtra("return_result", true);
startActivityForResult(intent, PLAY_CODE);
Why onActivityResult method receives null in intent data?
Also onActivityResult always receives result code RESULT_CANCELED.
Click to expand...
Click to collapse
I've run exact sample code but onActivityResult() returned RESULT_OK.
Check if uri is valid, if it is not pointing to a valid file, RESULT_CANCLED might be return.
bleu8888 said:
I've run exact sample code but onActivityResult() returned RESULT_OK.
Check if uri is valid, if it is not pointing to a valid file, RESULT_CANCLED might be return.
Click to expand...
Click to collapse
My uri is correct.
Can you try this uri?
Code:
Uri uri = Uri.parse("http:\\vs8*videoprobki*com*ua/tvukrbud/cam19.mp4");
And what about returning intent?
marievych said:
My uri is correct.
Can you try this uri?
Code:
Uri uri = Uri.parse("http:\\vs8*videoprobki*com*ua/tvukrbud/cam19.mp4");
And what about returning intent?
Click to expand...
Click to collapse
Replace "\\" with "//" and "*" with"."
marievych said:
Replace "" with "//" and "*" with"."
Click to expand...
Click to collapse
Works with no problem. resultCode is RESULT_OK and data is not null.
Tried following code:
Code:
String url = "YOUR_URL;
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setType("application/mp4");
intent.setData(uri);
intent.putExtra("position", 0);
intent.putExtra("return_result", true);
startActivityForResult(intent, 111);
Did you check logcat log? "return_result" should be printed out if the playback activity received intent extra correctly.
bleu8888 said:
Works with no problem. resultCode is RESULT_OK and data is not null.
Tried following code:
Code:
String url = "YOUR_URL;
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setType("application/mp4");
intent.setData(uri);
intent.putExtra("position", 0);
intent.putExtra("return_result", true);
startActivityForResult(intent, 111);
Did you check logcat log? "return_result" should be printed out if the playback activity received intent extra correctly.
Click to expand...
Click to collapse
Problem resolved by manual rewriting my code. What was wrong remaining mystery
I have exactly the same problem but I can't solve it. This is the way I create my Intent :
Code:
Uri uri = Uri.parse("http: // 172.20.0.101/media_directory/videos_10000319/videos_10000319_playlist_main.m3u8");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setDataAndType(uri, "application/mp4");
intent.putExtra(EXTRA_RETURN_RESULT, true);
startActivityForResult(intent, REQUEST_CODE_MXPLAYER);
The onActivityResult() methode i called with the correct requestCode but the resultCode is always RESULT_CANCELED and the intent is null..
As you can see, the Uri is a local network address, can it be the problem ?
kserin said:
I have exactly the same problem but I can't solve it. This is the way I create my Intent :
Code:
Uri uri = Uri.parse("http: // 172.20.0.101/media_directory/videos_10000319/videos_10000319_playlist_main.m3u8");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setPackage("com.mxtech.videoplayer.ad");
intent.setDataAndType(uri, "application/mp4");
intent.putExtra(EXTRA_RETURN_RESULT, true);
startActivityForResult(intent, REQUEST_CODE_MXPLAYER);
The onActivityResult() methode i called with the correct requestCode but the resultCode is always RESULT_CANCELED and the intent is null..
As you can see, the Uri is a local network address, can it be the problem ?
Click to expand...
Click to collapse
There are spaces before and after "//". Can MX play this url?
bleu8888 said:
There are spaces before and after "//". Can MX play this url?
Click to expand...
Click to collapse
Spaces are not actually present in my code (I add it here just to avoid my code be considered as SPAM).
kserin said:
Spaces are not actually present in my code (I add it here just to avoid my code be considered as SPAM).
Click to expand...
Click to collapse
Would you share logcat log? MX would leave some information.

Categories

Resources