Skip to content

Instantly share code, notes, and snippets.

@pbrewczynski
Created April 14, 2013 08:51
Show Gist options
  • Save pbrewczynski/5381996 to your computer and use it in GitHub Desktop.
Save pbrewczynski/5381996 to your computer and use it in GitHub Desktop.
package com.example.myfirstapp;
import android.telephony.SmsManager;
import android.net.Uri;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.annotation.SuppressLint;
import android.widget.TextView;
import com.example.myfirstapp.MainActivity;
import android.util.Log;
import android.media.MediaPlayer;
public class DisplayMessageActivity extends Activity {
/*
@SupressLint("NewApi")
@Overrride
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.avtivity_display_message);
// Make sure we've running on Honeycom or highter to use ActionBar APIs
//if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the up button in the action bar
//getActionBar().setDispalyHomeAsUpEnabled(true);
//}
Intent intent = getIntent();
String telNumber = intent.getStringExtra("telNumber");
int smsQuantity = intent.getIntExtra("smsQuantity",1);
String smsMessage = intent.getStringExtra("smsMessage");
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(smsMessage);
setContentView(textView);
MediaPlayer mPlayer = MediaPlayer.create(this,R.raw.oggone);
mPlayer.start();
}
//setContentView(R.layout.main);
/*
for(int i=0; i < smsQuantity;i+=1)
{
Log.w("myApp", String.valueOf(i));
Log.w("myApp", telNumber);
Log.w("myApp", String.valueOf(smsQuantity));
Log.w("myApp", smsMessage);
/*
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(telNumber, null, smsMessage , null, null);
}*/
/*
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
*/
}
E/AndroidRuntime( 2968): FATAL EXCEPTION: main
E/AndroidRuntime( 2968): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}: java.lang.NullPointerException
E/AndroidRuntime( 2968): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
E/AndroidRuntime( 2968): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
E/AndroidRuntime( 2968): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
E/AndroidRuntime( 2968): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
E/AndroidRuntime( 2968): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2968): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 2968): at android.app.ActivityThread.main(ActivityThread.java:3835)
E/AndroidRuntime( 2968): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2968): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 2968): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
E/AndroidRuntime( 2968): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
E/AndroidRuntime( 2968): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2968): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 2968): at com.example.myfirstapp.DisplayMessageActivity.onCreate(DisplayMessageActivity.java:44)
E/AndroidRuntime( 2968): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 2968): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
E/AndroidRuntime( 2968): ... 11 more
W/ActivityManager( 1073): Force finishing activity com.example.myfirstapp/.DisplayMessageActivity
W/ActivityManager( 1073): Force finishing activity com.example.myfirstapp/.MainActivity
W/ActivityManager( 1073): Activity pause timeout for HistoryRecord{408f4a70 com.example.myfirstapp/.DisplayMessageActivity}
W/ActivityManager( 1073): Activity destroy timeout for HistoryRecord{4077e2f0 com.example.myfirstapp/.MainActivity}
D/dalvikvm( 1714): GC_EXPLICIT freed 34K, 50% free 2695K/5379K, external 0K/0K, paused 45ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment