[android-developers] Receiving Intent

2013-03-06 Thread TWProgrammers
I am trying to get the file path of the intent. Everything I find doesn't 
seem to work. This is what I have so far:

Intent i = getIntent();
Uri uri = i.getData();
if (uri == null)
{
return;
}
String startFile = "";
try
{
startFile = uri.getPath();
}
catch (Exception ex)
{
Toast.makeText(this, "Error:\n" + ex.getMessage().toString(), 
Toast.LENGTH_LONG).show();
return;
}
if (startFile == null)
{
return;
}
StringBuilder text = new StringBuilder();  
   can = false;
   sel = false;
   try
   {
   file = new File(CurDir, startFile);
   reader = new BufferedReader(new FileReader(file));  
   String line;
   while ((line = reader.readLine()) != null)
   {
   text.append(line);  
   text.append('\n');  
   }
   }
   catch (Exception e)
   {
   Toast.makeText(this, "Error:\n" + e.getMessage().toString(), 
Toast.LENGTH_LONG).show();
   }
   TextEditor.setText(text);
   FileName.setText(startFile);

However if I open a file in "/mnt/sdcard/test.txt" it tries to open 
"/mnt/sdcard/mnt/sdcard/test.txt" this is frustrating me to no end... Any 
help is appreciated.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Receiving Intent

2013-03-07 Thread TWProgrammers












My app shows in the list for text files, I launch the file from a file 
manager such as ES File Explorer or IO File Manager: I click the file in 
the file manager at /mnt/sdcard/test.txt, the app list shows up, I click my 
app, it says it could not find /mnt/sdcard/mnt/sdcard/test.txt

On Wednesday, March 6, 2013 11:08:32 PM UTC-6, TreKing wrote:
>
> You need to provide more information.
>
> On Wed, Mar 6, 2013 at 10:33 PM, TWProgrammers 
> 
> > wrote:
>
>> I am trying to get the file path of the intent.
>>
>
> What intent?
>  
>
>> Everything I find doesn't seem to work.
>>
>
> Like what?
>  
>
>> However if I open a file in "/mnt/sdcard/test.txt"
>>
>
> Open a file how?
>  
>
>> it tries to open "/mnt/sdcard/mnt/sdcard/test.txt"
>>
>
> What is "it"?
>  
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago 
> transit tracking app for Android-powered devices
>  

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Receiving Intent

2013-03-07 Thread TWProgrammers
It just clicked what my problem was, I used:
file = new File(CurDir, startFile);
instead of:
file = new File(startFile);
because I just copied and pasted. I was going to reply I used the exact 
same code from opening inside the app, which made me think and backtrack my 
code. Thank you for helping me find this.

On Thursday, March 7, 2013 2:24:18 PM UTC-6, Mark Murphy (a Commons Guy) 
wrote:
>
> On Thu, Mar 7, 2013 at 3:03 PM, TWProgrammers 
> > 
> wrote: 
> > My app shows in the list for text files, I launch the file from a file 
> > manager such as ES File Explorer or IO File Manager: I click the file in 
> the 
> > file manager at /mnt/sdcard/test.txt, the app list shows up, I click my 
> app, 
> > it says it could not find /mnt/sdcard/mnt/sdcard/test.txt 
>
> Apparently there is a bug in your Java code where you are opening the 
> file. 
>
> -- 
> Mark Murphy (a Commons Guy) 
> http://commonsware.com | http://github.com/commonsguy 
> http://commonsware.com/blog | http://twitter.com/commonsguy 
>
> _The Busy Coder's Guide to Android Development_ Version 4.6 Available! 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Application Crash

2013-04-01 Thread TWProgrammers
I am trying to create an app that receives SMS messages and if it has a 
specific prefix it uses the information in it then deletes it. I have it 
where it shows no errors and seems like it would run but when ran it force 
closes. Here is my code:

SMSReceiver.java:

package com.TWP.Project.IES;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
import com.TWP.Project.IES.DenCryption;

public class SMSReceiver extends BroadcastReceiver
{
DenCryption decrypter = new DenCryption();
@Override
public void onReceive(Context context, Intent intent)
{
Bundle bundle = intent.getExtras();
Object messages[] = (Object[]) bundle.get("pdus");
SmsMessage smsMessage[] = new SmsMessage[messages.length];
for (int n = 0; n < messages.length; n++)
{
smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
if(smsMessage[0].getMessageBody().startsWith("*DenCryption3*:"))
{
String msg = 
smsMessage[0].getMessageBody().replace("*DenCryption3*:", "");
msg = decrypter.decrypt(msg);
Toast toast = Toast.makeText(context, msg, Toast.LENGTH_LONG);
toast.show();
abortBroadcast();
}
}
}


AndroidManifest.xml:

http://schemas.android.com/apk/res/android";
package="com.TWP.Project.IES"
android:versionCode="1"
android:versionName="1.0" >
















I am attaching the log from LogCat. I can't seem to find what my problem is.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


04-01 17:56:40.417: D/AndroidRuntime(581): Shutting down VM
04-01 17:56:40.417: W/dalvikvm(581): threadid=1: thread exiting with uncaught 
exception (group=0x40015560)
04-01 17:56:40.427: E/AndroidRuntime(581): FATAL EXCEPTION: main
04-01 17:56:40.427: E/AndroidRuntime(581): java.lang.RuntimeException: Unable 
to instantiate receiver com.TWP.Project.TDC.SMSReceiver: 
java.lang.ClassNotFoundException: com.TWP.Project.TDC.SMSReceiver in loader 
dalvik.system.PathClassLoader[/data/app/com.TWP.Project.IES-1.apk]
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
android.app.ActivityThread.handleReceiver(ActivityThread.java:1773)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
android.app.ActivityThread.access$2400(ActivityThread.java:117)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
android.os.Handler.dispatchMessage(Handler.java:99)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
android.os.Looper.loop(Looper.java:123)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
android.app.ActivityThread.main(ActivityThread.java:3683)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
java.lang.reflect.Method.invokeNative(Native Method)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
java.lang.reflect.Method.invoke(Method.java:507)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
dalvik.system.NativeStart.main(Native Method)
04-01 17:56:40.427: E/AndroidRuntime(581): Caused by: 
java.lang.ClassNotFoundException: com.TWP.Project.TDC.SMSReceiver in loader 
dalvik.system.PathClassLoader[/data/app/com.TWP.Project.IES-1.apk]
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-01 17:56:40.427: E/AndroidRuntime(581):  at 
android.app.ActivityThread.handleReceiver(ActivityThread.java:1764)
04-01 17:56:40.427: E/AndroidRuntime(581):  ... 10 more


[android-developers] Re: Application Crash

2013-04-02 Thread TWProgrammers
Did you not read the code?

On Monday, April 1, 2013 1:05:39 PM UTC-5, TWProgrammers wrote:
>
>  android:enabled="true">
> 
>  android:name="android.provider.Telephony.SMS_RECEIVED" />
> 
> 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Application Crash

2013-04-03 Thread TWProgrammers
A... I see my mistake. I am creating 2 apps that work together... 
Thanks!

On Tuesday, April 2, 2013 6:57:32 PM UTC-5, RichardC wrote:
>
> Error is: Unable to instantiate receiver com.TWP.Project.TDC.SMSReceive
> Source package is: com.TWP.Project.IES
> Source class is: SMSReceiver 
>
> "com.TWP.Project.TDC.SMSReceive" != "com.TWP.Project.IES.SMSReceiver"
>
> The class it is trying to instantiate does not match your source file 
> package name.
>
> On Wednesday, April 3, 2013 12:41:06 AM UTC+1, TWProgrammers wrote:
>>
>> Did you not read the code?
>>
>> On Monday, April 1, 2013 1:05:39 PM UTC-5, TWProgrammers wrote:
>>>
>>> >> android:enabled="true">
>>> 
>>> >> android:name="android.provider.Telephony.SMS_RECEIVED" />
>>> 
>>> 
>>>
>>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] SmsManager crashes app

2013-04-03 Thread TWProgrammers
I am trying to send a very long SMS message using SmsManager but when it 
hits that line it either crashes or throws a general error.

Here is my code:
private void execute(String phone)
{
PendingIntent sent = PendingIntent.getBroadcast(this, 0, new 
Intent("SMS_SENT"), 0);
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent", 
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure", 
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service", 
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU", 
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off", 
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter("SMS_SENT"));
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phone, null, e_msg.getText().toString(), sent, 
null);
send.setEnabled(false);
}

I am attaching the logcat logs.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


04-03 17:07:25.324: E/AndroidRuntime(492): FATAL EXCEPTION: main
04-03 17:07:25.324: E/AndroidRuntime(492): java.lang.NullPointerException
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
android.os.Parcel.readException(Parcel.java:1328)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
android.os.Parcel.readException(Parcel.java:1276)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:369)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
android.telephony.SmsManager.sendTextMessage(SmsManager.java:87)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
com.TWP.Project.TDC.Main.execute(Main.java:92)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
com.TWP.Project.TDC.Main.access$2(Main.java:60)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
com.TWP.Project.TDC.Main$3.onClick(Main.java:54)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
android.os.Handler.dispatchMessage(Handler.java:99)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
android.os.Looper.loop(Looper.java:123)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
android.app.ActivityThread.main(ActivityThread.java:3683)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
java.lang.reflect.Method.invokeNative(Native Method)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
java.lang.reflect.Method.invoke(Method.java:507)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-03 17:07:25.324: E/AndroidRuntime(492):  at 
dalvik.system.NativeStart.main(Native Method)
04-03 17:07:52.884: E/AndroidRuntime(505): FATAL EXCEPTION: main
04-03 17:07:52.884: E/AndroidRuntime(505): java.lang.NullPointerException
04-03 17:07:52.884: E/AndroidRuntime(505):  at 
android.os.Parcel.readException(Parcel.java:1328)
04-03 17:07:52.884: E/AndroidRuntime(505):  at 
android.os.Parcel.readException(Parcel.java:1276)
04-03 17:07:52.884: E/AndroidRuntime(505):  at 
com.android.internal.telephony.ISms$Stub$Proxy.sendText(ISms.java:369)
04-03 17:07:52.884: E/AndroidRuntime(505):  at 
android.telephony.SmsManager.sendTextMessage(S