Making a simple android app? - Android Q&A, Help & Troubleshooting

Hello.
I would like to make a very simple Android app, with no UI. Kind of a shortcut. I tried searching the web, and I didn't find what I was looking for.
The question is: Can I make a simple app, that only launches an activity?
I want to make an app to launch the following activity : "com.cyanogenmod.trebuchet.preference.Preferences". Kind of how the app "QuickShortcutMaker" works.
Thanks in advance for future answers.

I haven't much experience on android developer, but I think that this can do what you want.
Start a new project with an empty activity and put this inside the activity.java file:
Code:
public class MainActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.cyanogenmod.trebuchet.preference.Preferences");
startActivity(intent);
finish();
}
}

dancer_69 said:
I haven't much experience on android developer, but I think that this can do what you want.
Start a new project with an empty activity and put this inside the activity.java file:
Code:
public class MainActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.cyanogenmod.trebuchet.preference.Preferences");
startActivity(intent);
finish();
}
}
Click to expand...
Click to collapse
Thanks a lot for your help!
This line is giving me an error upon debug:
Code:
Intent intent = pm.getLaunchIntentForPackage("com.cyanogenmod.trebuchet.preference.Preferences");
The commands 'Intent intent" and "PackageManager" are not recognized. Eclipse suggests changing them, importing them, or creating a class. What should I do?
This is the logcat:
Code:
I/ActivityManager( 524): START u0 {act=android.intent.action.MAIN cat=[android.
intent.category.LAUNCHER] flg=0x10200000 cmp=com.AB.launchersettings/.MainActivi
ty} from pid 876
D/ALSAModule( 175): setHardwareParams: reqBuffSize 1024 channels 2 sampleRate 4
8000
D/ALSAModule( 175): setHardwareParams: buffer_size 2048, period_size 1024, peri
od_cnt 2
D/dalvikvm(26747): Late-enabling CheckJNI
I/ActivityManager( 524): Start proc com.AB.launchersettings for activity com.AB
.launchersettings/.MainActivity: pid=26747 uid=10046 gids={50046, 1028}
D/overlay ( 172): FROM_STATE = OV_BYPASS_3_LAYER TO_STATE = OV_CLOSED
E/Trace (26747): error opening trace file: No such file or directory (2)
D/AndroidRuntime(26747): Shutting down VM
W/dalvikvm(26747): threadid=1: thread exiting with uncaught exception (group=0x4
0a4a888)
E/AndroidRuntime(26747): FATAL EXCEPTION: main
E/AndroidRuntime(26747): java.lang.RuntimeException: Unable to start activity Co
mponentInfo{com.AB.launchersettings/com.AB.launchersettings.MainActivity}: java.
lang.NullPointerException
E/AndroidRuntime(26747): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2307)
E/AndroidRuntime(26747): at android.app.ActivityThread.handleLaunchActivi
ty(ActivityThread.java:2357)
E/AndroidRuntime(26747): at android.app.ActivityThread.access$600(Activit
yThread.java:153)
E/AndroidRuntime(26747): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1247)
E/AndroidRuntime(26747): at android.os.Handler.dispatchMessage(Handler.ja
va:99)
E/AndroidRuntime(26747): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(26747): at android.app.ActivityThread.main(ActivityThrea
d.java:5231)
E/AndroidRuntime(26747): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(26747): at java.lang.reflect.Method.invoke(Method.java:5
11)
E/AndroidRuntime(26747): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:794)
E/AndroidRuntime(26747): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:561)
E/AndroidRuntime(26747): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(26747): Caused by: java.lang.NullPointerException
E/AndroidRuntime(26747): at android.app.Instrumentation.execStartActivity
(Instrumentation.java:1410)
E/AndroidRuntime(26747): at android.app.Activity.startActivityForResult(A
ctivity.java:3376)
E/AndroidRuntime(26747): at android.app.Activity.startActivityForResult(A
ctivity.java:3337)
E/AndroidRuntime(26747): at android.app.Activity.startActivity(Activity.j
ava:3572)
E/AndroidRuntime(26747): at android.app.Activity.startActivity(Activity.j
ava:3540)
E/AndroidRuntime(26747): at com.AB.launchersettings.MainActivity.onCreate
(MainActivity.java:16)
E/AndroidRuntime(26747): at android.app.Activity.performCreate(Activity.j
ava:5110)
E/AndroidRuntime(26747): at android.app.Instrumentation.callActivityOnCre
ate(Instrumentation.java:1080)
E/AndroidRuntime(26747): at android.app.ActivityThread.performLaunchActiv
ity(ActivityThread.java:2261)
E/AndroidRuntime(26747): ... 11 more
W/ActivityManager( 524): Force finishing activity com.AB.launchersettings/.Ma
inActivity
D/dalvikvm( 524): GC_FOR_ALLOC freed 1154K, 23% free 26363K/33812K, paused 86ms
, total 86ms
W/BackupManagerService( 524): dataChanged but no participant pkg='com.android.p
roviders.settings' uid=10031
W/ActivityManager( 524): Activity pause timeout for ActivityRecord{40cbfcc8 u0
com.AB.launchersettings/.MainActivity}
D/alsa_ucm( 175): snd_use_case_set(): uc_mgr 0x2a0092a0 identifier _verb value
Inactive
D/alsa_ucm( 175): Set mixer controls for HiFi Lowlatency enable 0
D/alsa_ucm( 175): snd_use_case_set(): uc_mgr 0x2a0092a0 identifier _disdev valu
e Speaker
D/alsa_ucm( 175): Set mixer controls for Speaker enable 0
W/ActivityManager( 524): Activity destroy timeout for ActivityRecord{40cbfcc8 u
0 com.AB.launchersettings/.MainActivity}
What I did:
Created a new project ( Filled up the name, icon and stuff)
Went straight to MainActivity.java, and put what you gave me in it.
Debugged the app by installing it on my Nexus 4.

Import them.
EDIT:
Seems that the above code doesn't work. So replace all content on your activity, except the first line(com... what you have as name) with this:
Code:
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
public class MainActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent();
intent.setClassName("com.cyanogenmod.trebuchet", "com.cyanogenmod.trebuchet.preference.Preferences");
startActivity(intent);
finish();
}
}

dancer_69 said:
Import them.
EDIT:
Seems that the above code doesn't work. So replace all content on your activity, except the first line(com... what you have as name) with this:
Code:
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
public class MainActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent();
intent.setClassName("com.cyanogenmod.trebuchet", "com.cyanogenmod.trebuchet.preference.Preferences");
startActivity(intent);
finish();
}
}
Click to expand...
Click to collapse
This worked. Thanks a lot!!

Related

Unable to instantiate activity

Hello guys. So i'm trying to make a app that will play a aac stream from an online radio station. I managed to build the project but i get this error when running it.
Code:
05-27 06:12:00.734: E/AndroidRuntime(450): FATAL EXCEPTION: main
05-27 06:12:00.734: E/AndroidRuntime(450): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.spoledge.aacplay/com.spoledge.aacplay.AACPlayerActivity}: java.lang.ClassNotFoundException: com.spoledge.aacplay.AACPlayerActivity in loader dalvik.system.PathClassLoader[/data/app/com.spoledge.aacplay-2.apk]
05-27 06:12:00.734: E/AndroidRuntime(450): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
05-27 06:12:00.734: E/AndroidRuntime(450): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-27 06:12:00.734: E/AndroidRuntime(450): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-27 06:12:00.734: E/AndroidRuntime(450): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-27 06:12:00.734: E/AndroidRuntime(450): at android.os.Handler.dispatchMessage(Handler.java:99)
05-27 06:12:00.734: E/AndroidRuntime(450): at android.os.Looper.loop(Looper.java:123)
05-27 06:12:00.734: E/AndroidRuntime(450): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-27 06:12:00.734: E/AndroidRuntime(450): at java.lang.reflect.Method.invokeNative(Native Method)
05-27 06:12:00.734: E/AndroidRuntime(450): at java.lang.reflect.Method.invoke(Method.java:507)
05-27 06:12:00.734: E/AndroidRuntime(450): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-27 06:12:00.734: E/AndroidRuntime(450): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-27 06:12:00.734: E/AndroidRuntime(450): at dalvik.system.NativeStart.main(Native Method)
05-27 06:12:00.734: E/AndroidRuntime(450): Caused by: java.lang.ClassNotFoundException: com.spoledge.aacplay.AACPlayerActivity in loader dalvik.system.PathClassLoader[/data/app/com.spoledge.aacplay-2.apk]
05-27 06:12:00.734: E/AndroidRuntime(450): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-27 06:12:00.734: E/AndroidRuntime(450): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-27 06:12:00.734: E/AndroidRuntime(450): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-27 06:12:00.734: E/AndroidRuntime(450): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-27 06:12:00.734: E/AndroidRuntime(450): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
05-27 06:12:00.734: E/AndroidRuntime(450): ... 11 more
This is my project AACPlayerActivity.java code:
Code:
package com.spoledge.aacplay;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.spoledge.aacdecoder.AACPlayer;
import com.spoledge.aacdecoder.PlayerCallback;
/**
* This is the main activity.
*/
public class AACPlayerActivity extends Activity implements View.OnClickListener, PlayerCallback {
private History history;
private AutoCompleteTextView urlView;
private Button btnPlay;
private Button btnStop;
private TextView txtStatus;
private EditText txtBufAudio;
private EditText txtBufDecode;
private ProgressBar progress;
private Handler uiHandler;
private AACPlayer aacPlayer;
////////////////////////////////////////////////////////////////////////////
// PlayerCallback
////////////////////////////////////////////////////////////////////////////
private boolean playerStarted;
public void playerStarted() {
uiHandler.post( new Runnable() {
public void run() {
txtBufAudio.setEnabled( false );
txtBufDecode.setEnabled( false );
btnPlay.setEnabled( false );
btnStop.setEnabled( true );
txtStatus.setText( R.string.text_buffering );
progress.setProgress( 0 );
progress.setVisibility( View.VISIBLE );
playerStarted = true;
}
});
}
/**
* This method is called periodically by PCMFeed.
*
* @param isPlaying false means that the PCM data are being buffered,
* but the audio is not playing yet
*
* @param audioBufferSizeMs the buffered audio data expressed in milliseconds of playing
* @param audioBufferCapacityMs the total capacity of audio buffer expressed in milliseconds of playing
*/
public void playerPCMFeedBuffer( final boolean isPlaying,
final int audioBufferSizeMs, final int audioBufferCapacityMs ) {
uiHandler.post( new Runnable() {
public void run() {
progress.setProgress( audioBufferSizeMs * progress.getMax() / audioBufferCapacityMs );
if (isPlaying) txtStatus.setText( R.string.text_playing );
}
});
}
public void playerStopped( final int perf ) {
uiHandler.post( new Runnable() {
public void run() {
btnPlay.setEnabled( true );
btnStop.setEnabled( false );
txtBufAudio.setEnabled( true );
txtBufDecode.setEnabled( true );
// txtStatus.setText( R.string.text_stopped );
txtStatus.setText( "" + perf + " %" );
progress.setVisibility( View.INVISIBLE );
playerStarted = false;
}
});
}
public void playerException( final Throwable t) {
uiHandler.post( new Runnable() {
public void run() {
new AlertDialog.Builder( AACPlayerActivity.this )
.setTitle( R.string.text_exception )
.setMessage( t.toString())
.setNeutralButton( R.string.button_close,
new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog, int id) {
dialog.cancel();
}
}
)
.show();
txtStatus.setText( R.string.text_stopped );
if (playerStarted) playerStopped( 0 );
}
});
}
////////////////////////////////////////////////////////////////////////////
// OnClickListener
////////////////////////////////////////////////////////////////////////////
/**
* Called when a view has been clicked.
*/
public void onClick( View v ) {
try {
switch (v.getId()) {
case R.id.view_main_button_play: start(); break;
case R.id.view_main_button_stop: stop(); break;
}
}
catch (Exception e) {
Log.e( "AACPlayerActivity", "exc" , e );
}
}
////////////////////////////////////////////////////////////////////////////
// Protected
////////////////////////////////////////////////////////////////////////////
@Override
protected void onCreate( Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );
setContentView( R.layout.main );
btnPlay = (Button) findViewById( R.id.view_main_button_play );
btnStop = (Button) findViewById( R.id.view_main_button_stop );
urlView = (AutoCompleteTextView) findViewById( R.id.view_main_edit_url );
txtStatus = (TextView) findViewById( R.id.view_main_text_status );
txtBufAudio = (EditText) findViewById( R.id.view_main_text_bufaudio );
txtBufDecode = (EditText) findViewById( R.id.view_main_text_bufdecode );
progress = (ProgressBar) findViewById( R.id.view_main_progress );
txtBufAudio.setText( String.valueOf( AACPlayer.DEFAULT_AUDIO_BUFFER_CAPACITY_MS ));
txtBufDecode.setText( String.valueOf( AACPlayer.DEFAULT_DECODE_BUFFER_CAPACITY_MS ));
btnPlay.setOnClickListener( this );
btnStop.setOnClickListener( this );
history = new History( this );
history.read();
if (history.size() == 0 ) {
history.addUrl( "/sdcard/local/cro2-32.aac" );
history.addUrl( "netshow.play.cz:8000/crocb32aac" );
history.addUrl( "62.44.1.26:8000/cro2-128aac" );
history.addUrl( "2483.live.streamtheworld.com:80/KFTZFMAACCMP3" );
history.addUrl( "yourmuze.com:8000/play/paradise/l.aac" );
history.addUrl( "yourmuze.com:8000/play/paradise/m.aac" );
history.addUrl( "yourmuze.com:8000/play/paradise/h.aac" );
}
urlView.setAdapter( history.getArrayAdapter());
uiHandler = new Handler();
}
@Override
protected void onPause() {
super.onPause();
history.write();
}
@Override
protected void onDestroy() {
super.onDestroy();
stop();
}
////////////////////////////////////////////////////////////////////////////
// Private
////////////////////////////////////////////////////////////////////////////
private void start() {
stop();
aacPlayer = new AACPlayer( this, getInt( txtBufAudio ), getInt( txtBufDecode ));
aacPlayer.playAsync( getUrl());
}
private void stop() {
if (aacPlayer != null) {
aacPlayer.stop();
aacPlayer = null;
}
}
private String getUrl() {
String ret = urlView.getText().toString();
history.addUrl( ret );
return ret;
}
private int getInt( EditText et ) {
return Integer.parseInt( et.getText().toString());
}
}
And this is my AndroidManifest.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="schemas.android.com/apk/res/android"
package="com.spoledge.aacplay"
android:versionCode="1"
android:versionName="@string/app_version"
>
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="10"/>
<application
android:label="@string/app_name"
android:debuggable="true"
>
<activity
android:name="com.spoledge.aacplay.AACPlayerActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
So can someone help me solve this out? Thanks!
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums & Read the Forum Rules
Moving to Q&A
Here is your problem:
05-27 06:12:00.734: E/AndroidRuntime(450): Caused by: java.lang.ClassNotFoundException: com.spoledge.aacplay.AACPlayerActivity in loader dalvik.system.PathClassLoader[/data/app/com.spoledge.aacplay-2.apk]
Click to expand...
Click to collapse
are you using any external libraries?
are they exactly in libs directory in your project?

[Q] My code throws exceptions

Hello, i am new to development for android and i am trying to make a simple app for me to learn how to code in java.
The idea was to make an app that you can use to send a text (yes, i could just use the messaging app, but that's no fun) and after fiddling with my code quite a bit i made it run on the emulator.
everything works other than when i send the message; an error is thrown (sending a message using the messaging app works though, and the message appears on the other emulator)
The emulators are both running 4.0.3, only one has the app installed
here is the error:
Thread [<1> main] (Suspended (exception IllegalArgumentException))
and for the full stack you can visit this link: http://pastebin.com/Sdc4RshX
and for the code please go here: http://pastebin.com/4xXDTbD1
what would have caused the issue, and what should i do to fix it?
Thanks
Have you added the user permission in the android manifest for sending SMS?
Code:
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
learning Java under Android is a really bad idea, just learn how to use Java with the JDK under a desktop OS.
dillonr, check this:
cheznutts said:
Have you added the user permission in the android manifest for sending SMS?
Code:
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
Click to expand...
Click to collapse
Also, you need to provide a PendingIntent as fourth argument to sendTextMessage method (as described here).
i did/do have the permission in the android manifest
should edit the first post, i am trying to make a simple app to learn how to code in java for android...i have a few ideas for better apps, gotta learn the basics first.
i understand how the views work, and how the files are placed...so i'm learning some things, and it is similar to when i used to code a few years ago in flash (like classes, variables, if...etc.)
EDIT: i un-commented the parts i commented out previously (including the PendingIntent)
http://pastebin.com/cH4NMTwM
still throwing the same error
Thread [<1> main] (Suspended (exception IllegalArgumentException))
I also noticed this
SmsManager.sendTextMessage(String, String, String, PendingIntent, PendingIntent) line: 77
but i do not have a line 77, and nothing seems to be wrong with my code (that i can see, anyway)
Could you post your AndroidManifest.xml and layout XML would like to see the declarations.
manifest
http://pastebin.com/L6VU7bJV
layout
http://pastebin.com/yAB6ia4Q
ho[e this helps you help me
I went ahead and made a project using your code. I commented out the pending intent, I opened up two emulators. One with port 5554 and another with 5556. Now I compiled your code on 5556 and then text to 5554 and it went through fine, no exceptions. Here is what Im looking at in the Activity:
Code:
package com.example.test;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.telephony.SmsManager;
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public void csend(View view) {
String _number = this.getString(R.string.number);
String _message = this.getString(R.string.message);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(_number, null, _message, null, null);
}
}
Here is my Android Manifest:
Code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I left the layout alone. I say try it again. Check SDK is up to date and try creating new emulator using a different API level.
i updated and made new emulators (google api level 16, and google api level 15)
then i made a new "android application project" with the name 'multisender'
i copied the code from the previous application and pasted it into the correct files in the new one
what eclipse should i be running for android development? (on a mac)
running the application causes errors on sending the text (to phone number 15555215556 or 5556; the number shown when a text is recieved, and the port number)
it says "unfortunately, multisender has stopped." on the screen and i get errors in the LogCat
here is a copy of the LogCat errors
Code:
07-11 12:23:57.177: E/Trace(919): error opening trace file: No such file or directory (2)
07-11 12:29:33.907: E/Trace(954): error opening trace file: No such file or directory (2)
07-11 12:32:11.908: E/AndroidRuntime(954): FATAL EXCEPTION: main
07-11 12:32:11.908: E/AndroidRuntime(954): java.lang.IllegalStateException: Could not execute method of the activity
07-11 12:32:11.908: E/AndroidRuntime(954): at android.view.View$1.onClick(View.java:3591)
07-11 12:32:11.908: E/AndroidRuntime(954): at android.view.View.performClick(View.java:4084)
07-11 12:32:11.908: E/AndroidRuntime(954): at android.view.View$PerformClick.run(View.java:16966)
07-11 12:32:11.908: E/AndroidRuntime(954): at android.os.Handler.handleCallback(Handler.java:615)
07-11 12:32:11.908: E/AndroidRuntime(954): at android.os.Handler.dispatchMessage(Handler.java:92)
07-11 12:32:11.908: E/AndroidRuntime(954): at android.os.Looper.loop(Looper.java:137)
07-11 12:32:11.908: E/AndroidRuntime(954): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-11 12:32:11.908: E/AndroidRuntime(954): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:32:11.908: E/AndroidRuntime(954): at java.lang.reflect.Method.invoke(Method.java:511)
07-11 12:32:11.908: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-11 12:32:11.908: E/AndroidRuntime(954): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-11 12:32:11.908: E/AndroidRuntime(954): at dalvik.system.NativeStart.main(Native Method)
07-11 12:32:11.908: E/AndroidRuntime(954): Caused by: java.lang.reflect.InvocationTargetException
07-11 12:32:11.908: E/AndroidRuntime(954): at java.lang.reflect.Method.invokeNative(Native Method)
07-11 12:32:11.908: E/AndroidRuntime(954): at java.lang.reflect.Method.invoke(Method.java:511)
07-11 12:32:11.908: E/AndroidRuntime(954): at android.view.View$1.onClick(View.java:3586)
07-11 12:32:11.908: E/AndroidRuntime(954): ... 11 more
07-11 12:32:11.908: E/AndroidRuntime(954): Caused by: java.lang.IllegalArgumentException: Invalid destinationAddress
07-11 12:32:11.908: E/AndroidRuntime(954): at android.telephony.SmsManager.sendTextMessage(SmsManager.java:77)
07-11 12:32:11.908: E/AndroidRuntime(954): at com.dillonregi.multisender.multisender.csend(multisender.java:71)
07-11 12:32:11.908: E/AndroidRuntime(954): ... 14 more
it seems like i have an "invalid destination address" but sending a text to those numbers works in the default sms app
and what would be the "method of the activity"?
sorry for all these questions, but maybe one day someone else will also have this problem
EDIT: so i found the problem...kind of...when i replaced the line
sms.sendTextMessage(_number, null, _message, sentPI, null);
with
sms.sendTextMessage("5556", null, "test", null, null);
and ran it on the emulator (on port 5554) it sent "test" to the one on port 5556 with no errors!
Still wondering why i was getting errors with the variables there though
second edit: if either of the _number or _message variables are on that line it breaks...sentPI does not break it
okay, so i found the problem with the _number and _message
they were not defined in my strings.xml
the only problem is i cannot change who i send it to, or what the message is, even when i change what the text boxes say in the application...so my new question is how can i change a variable using an editable text box? (or how can i check what is in the text box before sending the text?)
EDIT: okay, i think i fixed it....
"
EditText number = (EditText)findViewById(R.id.pnumber);
EditText message = (EditText)findViewById(R.id.pmessage);
String _number = number.getText().toString();
String _message = message.getText().toString();
"
then
" sms.sendTextMessage(_number, null, _message, sentPI, null);
"
hope this helps other people
thanks everyone

NetworkOnMainThreadException error in jellybean

I've been trying to get this to work for the last week or so and still have no idea what the problem is. it works on android 2.1 but not on 4.1. ive got this string in a service that check for updates in my app.
Code:
latestVersion = Integer.parseInt(getHttpString(urlLatestVersion));
its called in checkForUpdate(); which is called in onStart(Intent intent, int startId);.
Code:
private String getHttpString(String urlString) throws IOException {
InputStream in = null;
int response = -1;
URL url = new URL(urlString);
URLConnection conn = url.openConnection();
if (!(conn instanceof HttpURLConnection))
throw new IOException("Not an HTTP connection");
try {
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setAllowUserInteraction(false);
httpConn.setInstanceFollowRedirects(true);
httpConn.setRequestMethod("GET");
httpConn.connect();
response = httpConn.getResponseCode();
if (response == HttpURLConnection.HTTP_OK) {
in = httpConn.getInputStream();
}
} catch (Exception ex) {
ex.printStackTrace();
//
//main error currently lies here
// TODO fix errors that accures on android 4.0 and above.
//
}
if (in != null) {
StringBuilder sb = new StringBuilder();
String line;
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(in, "UTF-8"));
while ((line = reader.readLine()) != null) {
sb.append(line); // .append("\n");
}
} finally {
in.close();
}
return sb.toString();
} else
return "";
}
this is the error from the logcat
Code:
W/System.err( 7077): android.os.NetworkOnMainThreadException
W/System.err( 7077): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
W/System.err( 7077): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
W/System.err( 7077): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
W/System.err( 7077): at java.net.InetAddress.getAllByName(InetAddress.java:214)
W/System.err( 7077): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
W/System.err( 7077): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
W/System.err( 7077): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
W/System.err( 7077): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
W/System.err( 7077): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
W/System.err( 7077): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
W/System.err( 7077): at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
W/System.err( 7077): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
W/System.err( 7077): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
W/System.err( 7077): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
W/System.err( 7077): at com.lukemovement.roottoolbox.pro.Update.getHttpString(Update.java:166)
W/System.err( 7077): at com.lukemovement.roottoolbox.pro.Update.checkForUpdate(Update.java:98)
W/System.err( 7077): at com.lukemovement.roottoolbox.pro.Update.onStart(Update.java:75)
W/System.err( 7077): at android.app.Service.onStartCommand(Service.java:450)
W/System.err( 7077): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2620)
W/System.err( 7077): at android.app.ActivityThread.access$1900(ActivityThread.java:143)
W/System.err( 7077): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1306)
W/System.err( 7077): at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 7077): at android.os.Looper.loop(Looper.java:137)
W/System.err( 7077): at android.app.ActivityThread.main(ActivityThread.java:4935)
W/System.err( 7077): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 7077): at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 7077): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
W/System.err( 7077): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
W/System.err( 7077): at dalvik.system.NativeStart.main(Native Method)
I/Example update( 7077): Invalid int: ""
so has android given up on being backwards compatible or have just just forgotten to add this bit in?
ive read that i need to use AsyncTask. but i cant seem to get it to work for me, could anyone help me with this please?
replaced
Code:
@Override
public void onStart(final Intent intent, int startId) {
with
Code:
@Override
public void onStart(final Intent intent, int startId) {
new Thread(new Runnable(){
@Override
public void run() {
fix the issue instantly.
lukemovement1 said:
replaced
Code:
@Override
public void onStart(final Intent intent, int startId) {
with
Code:
@Override
public void onStart(final Intent intent, int startId) {
new Thread(new Runnable(){
@Override
public void run() {
fix the issue instantly.
Click to expand...
Click to collapse
Yep!
You can't run your network requests on main thread. Use have to use AsyncTask. http://developer.android.com/reference/android/os/AsyncTask.html

[APP] CalendarCG.apk problem + Phone Apk building problem

Dear all,
i'm Fabrizio from Italy and i'm happy to be a new members of the forum.
I hope that this is a correct section :
I've two big problems with my android phone:
FIRST PROBLEM -CALENDARCG.APK If the phone is setting in english language , i can open the calendar, i can insert new event, i can edit event.
If i shift the phone in another language setting ( italian,french,german or other) i can open the calendar, but when i try to insert a new event,
i receive follow alert : "The application Calendar (process.com.android.calendar) has stopped unexpectedly. Please try again." - and asked to force close.
I tried to reset the phone, hard rest the hone, clear data but nothing..always same problem.
Please can you help me to solve these problem?? Have i to modify the AndroidManifest or what?
SECOND PROBLEM - PHONE.APK SOLVED
I decompiled Phone.apk( i've android 4.0.4 - multi apk tool with apktool 1.5.0- and i have to change translation on value-it ) without problem, and i tried to rebuild them (without change any file) and i received following error:
Code:
--------------------------------------------------------------------------
|05/12/2012 -- 22:08:37,87|
--------------------------------------------------------------------------
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)
I: Loading resource table...
W: Skipping "android" package group
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\fakate\apktool\framework\1.apk
I: Loaded.
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
D:\android\APK\other\..\projects\Phone.apk\res\values\arrays.xml:158: error: Found tag reference-array where item is expected
D:\android\APK\other\..\projects\Phone.apk\res\values-nl\arrays.xml:131: error: Found tag reference-array where item is expected
D:\android\APK\other\..\projects\Phone.apk\res\values-pt-rPT\arrays.xml:131: error: Found tag reference-array where item is expected
D:\android\APK\other\..\projects\Phone.apk\res\values-es\strings.xml:248: error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
D:\android\APK\other\..\projects\Phone.apk\res\values-es\strings.xml:249: error: Unexpected end tag string
D:\android\APK\other\..\projects\Phone.apk\res\values-it\strings.xml:248: error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
D:\android\APK\other\..\projects\Phone.apk\res\values-it\strings.xml:249: error: Unexpected end tag string
D:\android\APK\other\..\projects\Phone.apk\res\values-ru\strings.xml:212: error: Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
D:\android\APK\other\..\projects\Phone.apk\res\values-ru\strings.xml:213: error: Unexpected end tag string
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:702: error: Public entry identifier 0x7f06002f entry index is larger than available symbols (index 47, total symbols 40).
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:702: error: Public symbol array/cdma_subscription_choices declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:695: error: Public entry identifier 0x7f060028 entry index is larger than available symbols (index 40, total symbols 40).
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:695: error: Public symbol array/cdma_subscription_values declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:689: error: Public symbol array/cdma_system_select_values declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:698: error: Public entry identifier 0x7f06002b entry index is larger than available symbols (index 43, total symbols 40).
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:698: error: Public symbol array/dtmf_tone_entries declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:699: error: Public symbol array/dtmf_tone_values declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:703: error: Public entry identifier 0x7f060030 entry index is larger than available symbols (index 48, total symbols 40).
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:703: error: Public symbol array/subscription_values declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:700: error: Public symbol array/td_network_mode_choices declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:701: error: Public symbol array/td_network_mode_values declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:696: error: Public entry identifier 0x7f060029 entry index is larger than available symbols (index 41, total symbols 40).
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:696: error: Public symbol array/tty_mode_entries declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:697: error: Public symbol array/tty_mode_values declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:674: error: Public symbol array/vt_incall_video_setting_entries2 declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:675: error: Public symbol array/vt_incall_video_setting_local_nightmode_entries declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:676: error: Public symbol array/vt_incall_video_setting_local_nightmode_entries2 declared here is not defined.
D:\android\APK\other\..\projects\Phone.apk\res\values\public.xml:677: error: Public symbol array/vt_incall_video_setting_peer_quality_entries declared here is not defined.
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 10, --target-sdk-version, 10, -F, C:\Users\fakate\AppData\Local\Temp\APKTOOL5211967303135877753.tmp, -I, C:\Users\fakate\apktool\framework\1.apk, -S, D:\android\APK\other\..\projects\Phone.apk\res, -M, D:\android\APK\other\..\projects\Phone.apk\AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:255)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:324)
at brut.androlib.Androlib.buildResources(Androlib.java:269)
at brut.androlib.Androlib.build(Androlib.java:192)
at brut.androlib.Androlib.build(Androlib.java:174)
at brut.apktool.Main.cmdBuild(Main.java:188)
at brut.apktool.Main.main(Main.java:70)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 10, --target-sdk-version, 10, -F, C:\Users\fakate\AppData\Local\Temp\APKTOOL5211967303135877753.tmp, -I, C:\Users\fakate\apktool\framework\1.apk, -S, D:\android\APK\other\..\projects\Phone.apk\res, -M, D:\android\APK\other\..\projects\Phone.apk\AndroidManifest.xml]
at brut.util.OS.exec(OS.java:83)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:253)
... 6 more
How i can solve both problems?
Tnx in advance for your help,
Courtesy up
Up
Sent from my 4S clone using xda app-developers app
Up again
Sent from my 4S clone using xda app-developers app
Hi, Phone.apk building problem solved.
Now remain the problem of calendarCG.
Please can suggets me an evenual solution?
Tnx,
Fabrizio
HI,attached teh APK.
I supose that the problem is in the dex file.......
flagello79 said:
HI,attached teh APK.
I supose that the problem is in the dex file.......
Click to expand...
Click to collapse
Sorry for double post,
but yesterday i attached wrong file.
The correct file are below.
Please note that th efile CAlendarCG.odex.zi is only renamed ( remove .zip to have original odex file)
Thx for your support in this case
Rgds,
Fabrizio
This is the log
Code:
12-09 12:13:49.649 I/ActivityManager(163): Start proc com.android.providers.calendar for content provider com.android.providers.calendar/.CalendarProvider2: pid=1582 uid=10006 gids={3003}
12-09 12:13:49.650 E/look-----------------------------------------------(1573): 31
12-09 12:13:49.679 I/SurfaceFlinger(163): [SurfaceFlinger] statistic - FrameCount: 120, Duration: 4290277us, fps: 27.970222
12-09 12:13:49.723 V/ActivityManager(163): Binding process pid 1582 to record ProcessRecord{40a22528 1582:com.android.providers.calendar/10006}
12-09 12:13:49.723 V/ActivityManager(163): New death recipient [email protected]0a359a0 for thread [email protected]
12-09 12:13:49.724 V/ActivityManager(163): New app record ProcessRecord{40a22528 1582:com.android.providers.calendar/10006} [email protected] pid=1582
Sent from my 4S using xda app-developers app
And Aldo this one:
Code:
12-09 12:59:08.000 E/InputDispatcher(163): channel '40a630d0 com.android.calendar/com.android.calendar.MonthActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
12-09 12:59:08.000 E/InputDispatcher(163): channel '40a630d0 com.android.calendar/com.android.calendar.MonthActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
Sent from my 4S using xda app-developers app
And this us the log when i've the phone setting language in english:
Code:
12-09 14:30:45.378 I/ActivityManager(163): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.calendar/.LaunchActivity bnds=[320,576][472,740] } from pid 287
12-09 14:30:45.527 I/ActivityManager(163): Start proc com.android.calendar for activity com.android.calendar/.LaunchActivity: pid=3180 uid=10006 gids={3003}
12-09 14:30:45.615 V/ActivityManager(163): Binding process pid 3180 to record ProcessRecord{40ade2d8 3180:com.android.calendar/10006}
12-09 14:30:45.615 V/ActivityManager(163): New app record ProcessRecord{40ade2d8 3180:com.android.calendar/10006} [email protected] pid=3180
12-09 14:30:45.616 V/ActivityManager(163): Launching: HistoryRecord{40a270d8 com.android.calendar/.LaunchActivity}
12-09 14:30:45.760 E/LaunchActivity(3180): onAccountsLoaded startActivity: com.android.calendar.MonthActivity
12-09 14:30:45.760 I/ActivityManager(163): Starting: Intent { flg=0x20020000 cmp=com.android.calendar/.MonthActivity } from pid 3180
12-09 14:30:45.768 V/ActivityManager(163): Enqueueing pending finish: HistoryRecord{40a270d8 com.android.calendar/.LaunchActivity}
12-09 14:30:45.768 V/ActivityManager(163): Launching: HistoryRecord{40c148e0 com.android.calendar/.MonthActivity}
12-09 14:30:46.138 I/CalendarProvider(1582): CalendarProvider2: query,uri=content://com.android.calendar/properties
12-09 14:30:46.160 I/CalendarProvider(1582): CalendarProvider2: query,uri=content://com.android.calendar/instances/whenbyday/2456271/2456271
12-09 14:30:46.166 I/CalendarProvider(1582): CalendarProvider2: query,uri=content://com.android.calendar/instances/whenbyday/2456271/2456271
12-09 14:30:46.172 I/CalendarProvider(1582): CalendarProvider2: query,uri=content://com.android.calendar/instances/whenbyday/2456271/2456271
12-09 14:30:46.180 I/CalendarProvider(1582): CalendarProvider2: query,uri=content://com.android.calendar/instances/whenbyday/2456271/2456271
12-09 14:30:46.228 I/CalendarProvider(1582): CalendarProvider2: query,uri=content://com.android.calendar/instances/groupbyday/2456263/2456293
12-09 14:30:46.474 V/ActivityManager(163): Activity idle: HistoryRecord{40c148e0 com.android.calendar/.MonthActivity}
12-09 14:30:46.580 I/ActivityManager(163): [AppLaunch] Displayed com.android.calendar/.MonthActivity: +812ms (total +1s150ms)
12-09 14:30:46.580 D/ActivityManager(163): AP_PROF:AppLaunch_LaunchTime:com.android.calendar/.MonthActivity:812:4344566
12-09 14:30:47.190 I/ActivityManager(163): Starting: Intent { act=android.intent.action.EDIT cmp=com.android.calendar/.EditEvent (has extras) } from pid 3180
12-09 14:30:47.203 V/ActivityManager(163): Launching: HistoryRecord{40a97848 com.android.calendar/.EditEvent}
12-09 14:30:47.443 I/CalendarProvider(1582): CalendarProvider2: query,uri=content://com.android.calendar/calendars
12-09 14:30:47.666 V/ActivityManager(163): Activity idle: HistoryRecord{40a97848 com.android.calendar/.EditEvent}
12-09 14:30:47.666 V/ActivityManager(163): Stopping HistoryRecord{40c148e0 com.android.calendar/.MonthActivity}: nowVisible=false waitingVisible=true finishing=false
12-09 14:30:47.875 I/ActivityManager(163): [AppLaunch] Displayed com.android.calendar/.EditEvent: +671ms
12-09 14:30:47.875 D/ActivityManager(163): AP_PROF:AppLaunch_LaunchTime:com.android.calendar/.EditEvent:671:4345860
12-09 14:30:47.875 V/ActivityManager(163): Stopping HistoryRecord{40c148e0 com.android.calendar/.MonthActivity}: nowVisible=true waitingVisible=false finishing=false
12-09 14:30:47.875 V/ActivityManager(163): Ready to stop: HistoryRecord{40c148e0 com.android.calendar/.MonthActivity}
12-09 14:30:47.883 V/ActivityManager(163): Activity stopped: token=HistoryRecord{40c148e0 com.android.calendar/.MonthActivity}
12-09 14:30:48.338 I/ActivityManager(163): Starting: Intent { cmp=com.android.calendar/.StartAndEndActivity (has extras) } from pid 3180
12-09 14:30:48.368 V/ActivityManager(163): Launching: HistoryRecord{40b06ef0 com.android.calendar/.StartAndEndActivity}
12-09 14:30:48.765 V/ActivityManager(163): Activity idle: HistoryRecord{40b06ef0 com.android.calendar/.StartAndEndActivity}
12-09 14:30:48.766 V/ActivityManager(163): Stopping HistoryRecord{40a97848 com.android.calendar/.EditEvent}: nowVisible=false waitingVisible=true finishing=false
12-09 14:30:48.889 I/ActivityManager(163): [AppLaunch] Displayed com.android.calendar/.StartAndEndActivity: +521ms
12-09 14:30:48.889 D/ActivityManager(163): AP_PROF:AppLaunch_LaunchTime:com.android.calendar/.StartAndEndActivity:521:4346875
12-09 14:30:48.889 V/ActivityManager(163): Stopping HistoryRecord{40a97848 com.android.calendar/.EditEvent}: nowVisible=true waitingVisible=false finishing=false
Sent from my 4S using xda app-developers app
Up
Sent from my 4S using xda app-developers app
up again:banghead::banghead::banghead::banghead:
Sent from my 4S using xda app-developers app
THIS IS A COMPLETE ERROR LOG
Code:
12-11 22:14:57.342 V/AlarmManager(182): 6: dic 12 12:08:00 p. com.android.providers.calendar
12-11 22:15:28.049 I/ActivityManager(182): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.calendar/.LaunchActivity bnds=[320,576][472,740] } from pid 13361
12-11 22:15:28.117 I/ActivityManager(182): Start proc com.android.calendar for activity com.android.calendar/.LaunchActivity: pid=25243 uid=10006 gids={3003}
12-11 22:15:28.173 V/ActivityManager(182): Binding process pid 25243 to record ProcessRecord{406ab498 25243:com.android.calendar/10006}
12-11 22:15:28.173 V/ActivityManager(182): New app record ProcessRecord{406ab498 25243:com.android.calendar/10006} [email protected] pid=25243
12-11 22:15:28.174 V/ActivityManager(182): Launching: HistoryRecord{405467f8 com.android.calendar/.LaunchActivity}
12-11 22:15:28.275 E/LaunchActivity(25243): onAccountsLoaded startActivity: com.android.calendar.MonthActivity
12-11 22:15:28.276 I/ActivityManager(182): Starting: Intent { flg=0x20020000 cmp=com.android.calendar/.MonthActivity } from pid 25243
12-11 22:15:28.278 V/ActivityManager(182): Enqueueing pending finish: HistoryRecord{405467f8 com.android.calendar/.LaunchActivity}
12-11 22:15:28.279 V/ActivityManager(182): Launching: HistoryRecord{40546a50 com.android.calendar/.MonthActivity}
12-11 22:15:28.701 I/ActivityManager(182): Start proc com.android.providers.calendar for content provider com.android.providers.calendar/.CalendarProvider2: pid=25252 uid=10006 gids={3003}
12-11 22:15:28.771 V/ActivityManager(182): Binding process pid 25252 to record ProcessRecord{406bb860 25252:com.android.providers.calendar/10006}
12-11 22:15:28.771 V/ActivityManager(182): New app record ProcessRecord{406bb860 25252:com.android.providers.calendar/10006} [email protected] pid=25252
12-11 22:15:28.796 I/ActivityThread(25252): Pub com.android.calendar: com.android.providers.calendar.CalendarProvider2
12-11 22:15:28.856 I/CalendarProvider(25252): onAccountsUpdated.
12-11 22:15:28.942 I/CalendarProvider(25252): AccountManager data account,nae=XXXXXXXXXXXX,type=com.google
12-11 22:15:28.943 I/CalendarProvider(25252): AccountManager data account,nae=XXXXXXXXXXXXXt,type=com.facebook.auth.login
12-11 22:15:28.943 I/CalendarProvider(25252): AccountManager data account,nae=XXXXXXXXXXXX,type=com.whatsapp
12-11 22:15:28.961 I/CalendarProvider(25252): CalendarProvider2: query,uri=content://com.android.calendar/properties
12-11 22:15:28.967 I/CalendarProvider(25252): CalendarProvider2: query,uri=content://com.android.calendar/instances/whenbyday/2456273/2456273
12-11 22:15:28.988 I/CalendarProvider(25252): CalendarProvider2: query,uri=content://com.android.calendar/instances/whenbyday/2456273/2456273
12-11 22:15:29.023 I/CalendarProvider(25252): CalendarProvider2: query,uri=content://com.android.calendar/calendar_alerts
12-11 22:15:29.039 I/CalendarProvider(25252): CalendarProvider2: query,uri=content://com.android.calendar/instances/groupbyday/2456263/2456293
12-11 22:15:29.140 D/Calendar(25252): missed alarms found: 0
12-11 22:15:29.148 I/ActivityManager(182): [AppLaunch] Displayed com.android.calendar/.MonthActivity: +870ms (total +1s36ms)
12-11 22:15:29.148 D/ActivityManager(182): AP_PROF:AppLaunch_LaunchTime:com.android.calendar/.MonthActivity:870:55329649
12-11 22:15:29.184 V/ActivityManager(182): Activity idle: HistoryRecord{40546a50 com.android.calendar/.MonthActivity}
12-11 22:15:30.511 I/ActivityManager(182): Starting: Intent { act=android.intent.action.EDIT cmp=com.android.calendar/.EditEvent (has extras) } from pid 25243
12-11 22:15:30.526 V/ActivityManager(182): Launching: HistoryRecord{40546dc0 com.android.calendar/.EditEvent}
12-11 22:15:30.770 I/CalendarProvider(25252): CalendarProvider2: query,uri=content://com.android.calendar/calendars
12-11 22:15:31.015 V/ActivityManager(182): Activity idle: HistoryRecord{40546dc0 com.android.calendar/.EditEvent}
12-11 22:15:31.016 V/ActivityManager(182): Stopping HistoryRecord{40546a50 com.android.calendar/.MonthActivity}: nowVisible=false waitingVisible=true finishing=false
12-11 22:15:31.224 I/ActivityManager(182): [AppLaunch] Displayed com.android.calendar/.EditEvent: +698ms
12-11 22:15:31.224 D/ActivityManager(182): AP_PROF:AppLaunch_LaunchTime:com.android.calendar/.EditEvent:698:55331725
12-11 22:15:31.225 V/ActivityManager(182): Stopping HistoryRecord{40546a50 com.android.calendar/.MonthActivity}: nowVisible=true waitingVisible=false finishing=false
12-11 22:15:31.225 V/ActivityManager(182): Ready to stop: HistoryRecord{40546a50 com.android.calendar/.MonthActivity}
12-11 22:15:31.229 V/ActivityManager(182): Activity stopped: token=HistoryRecord{40546a50 com.android.calendar/.MonthActivity}
12-11 22:15:31.787 I/ActivityManager(182): Starting: Intent { cmp=com.android.calendar/.StartAndEndActivity (has extras) } from pid 25243
12-11 22:15:31.818 V/ActivityManager(182): Launching: HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}
12-11 22:15:32.012 W/ActivityManager(182): Force finishing activity com.android.calendar/.StartAndEndActivity
12-11 22:15:32.014 W/ActivityManager(182): Force finishing activity com.android.calendar/.EditEvent
12-11 22:15:32.014 V/ActivityManager(182): Enqueueing pending finish: HistoryRecord{40546dc0 com.android.calendar/.EditEvent}
12-11 22:15:32.183 D/AES (182): process : com.android.calendar
12-11 22:15:32.183 D/AES (182): module : com.android.calendar v10 (4.0.4)
12-11 22:15:32.186 D/AEE/LIBAEE(182): shell: raise_exp(2, 25243, -1361051648, com.android.calendar, 0x0x633db8, 0x0x0)
12-11 22:15:32.186 E/AEE/LIBAEE(182): read_cmdline:com.android.calendar
12-11 22:15:32.513 W/ActivityManager(182): Activity pause timeout for HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}
12-11 22:15:32.513 V/ActivityManager(182): Enqueueing pending finish: HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}
12-11 22:15:34.083 I/ActivityManager(182): Process com.android.calendar (pid 25243) has died.
12-11 22:15:34.083 V/ActivityManager(182): Dying app: ProcessRecord{406ab498 25243:com.android.calendar/10006}, pid: 25243, thread: [email protected]
12-11 22:15:34.083 V/ActivityManager(182): Removing app ProcessRecord{406ab498 0:com.android.calendar/10006} from list [HistoryRecord{40545a68 com.android.browser/.BrowserActivity}, HistoryRecord{409d0738 com.android.contacts/.DialtactsActivity}, HistoryRecord{40549ca8 com.android.mms/.ui.ConversationList}, HistoryRecord{40b0afc0 com.android.phone/.InCallScreen}, HistoryRecord{40a73bc0 com.android.launcher/.Launcher}, HistoryRecord{40546dc0 com.android.calendar/.EditEvent}, HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}, HistoryRecord{40546a50 com.android.calendar/.MonthActivity}] with 8 entries
12-11 22:15:34.084 V/ActivityManager(182): Record #7 HistoryRecord{40546a50 com.android.calendar/.MonthActivity}: app=ProcessRecord{406ab498 0:com.android.calendar/10006}
12-11 22:15:34.084 V/ActivityManager(182): Record #6 HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}: app=ProcessRecord{406ab498 0:com.android.calendar/10006}
12-11 22:15:34.084 V/ActivityManager(182): Record #5 HistoryRecord{40546dc0 com.android.calendar/.EditEvent}: app=ProcessRecord{406ab498 0:com.android.calendar/10006}
12-11 22:15:34.084 V/ActivityManager(182): Removing app ProcessRecord{406ab498 0:com.android.calendar/10006} from list [] with 0 entries
12-11 22:15:34.084 V/ActivityManager(182): Removing app ProcessRecord{406ab498 0:com.android.calendar/10006} from list [HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}] with 1 entries
12-11 22:15:34.084 V/ActivityManager(182): Record #0 HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}: app=ProcessRecord{406ab498 0:com.android.calendar/10006}
12-11 22:15:34.084 V/ActivityManager(182): Removing app ProcessRecord{406ab498 0:com.android.calendar/10006} from list [HistoryRecord{40546dc0 com.android.calendar/.EditEvent}, HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}] with 2 entries
12-11 22:15:34.084 V/ActivityManager(182): Record #1 HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}: app=ProcessRecord{406ab498 0:com.android.calendar/10006}
12-11 22:15:34.084 V/ActivityManager(182): Record #0 HistoryRecord{40546dc0 com.android.calendar/.EditEvent}: app=ProcessRecord{406ab498 0:com.android.calendar/10006}
12-11 22:15:34.084 V/ActivityManager(182): Removing app ProcessRecord{406ab498 0:com.android.calendar/10006} from history with 9 entries
12-11 22:15:34.084 V/ActivityManager(182): Record #8 HistoryRecord{40547250 com.android.calendar/.StartAndEndActivity}: app=ProcessRecord{406ab498 0:com.android.calendar/10006}
12-11 22:15:34.087 E/InputDispatcher(182): channel '4054b4c8 com.android.calendar/com.android.calendar.MonthActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x8
12-11 22:15:34.087 E/InputDispatcher(182): channel '4054b4c8 com.android.calendar/com.android.calendar.MonthActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
12-11 22:15:34.091 V/ActivityManager(182): Record #7 HistoryRecord{40546dc0 com.android.calendar/.EditEvent}: app=ProcessRecord{406ab498 0:com.android.calendar/10006}
12-11 22:15:34.095 I/WindowManager(182): WIN DEATH: Window{40568fb8 com.android.calendar/com.android.calendar.EditEvent paused=true}
No suggestion?no idea?
Sent from my 4S using xda app-developers app
Up
Sent from my 4S using xda app-developers app
..and finally MONTH ACTIVITY.class
PLEASE GIVE ME HELP TO FIND THE PROBLEM AND TO SOLVE THE BUG,SO I CAN USE THE CALENDAR ALSO WHE LANGUAGE PHONE SETTING IS IN ITALIAN,OR FRENCH,OR ANY OTHER LANGUAGES!
Code:
package com.android.calendar;
import android.app.Activity;
import android.content.*;
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.text.format.*;
import android.view.*;
import android.view.animation.*;
import android.widget.*;
import com.android.iphoneview.iphoneUtils;
import java.util.*;
// Referenced classes of package com.android.calendar:
// Navigator, MonthView, Utils, AgendaActivity,
// DayActivity, CalendarPreferenceActivity, EditEvent, EventLoader,
// CalendarApplication
public class MonthActivity extends Activity
implements android.widget.ViewSwitcher.ViewFactory, Navigator, android.view.animation.Animation.AnimationListener, android.view.View.OnClickListener
{
public MonthActivity()
{
mUpdateTZ = new _cls1();
oldlines = 0;
mIntentReceiver = new _cls2();
mObserver = new _cls3(new Handler());
}
void eventsChanged()
{
((MonthView)mSwitcher.getCurrentView()).reloadEvents();
}
public boolean getAllDay()
{
return false;
}
public long getSelectedTime()
{
return ((MonthView)mSwitcher.getCurrentView()).getSelectedTimeInMillis();
}
int getStartDay()
{
return mStartDay;
}
protected ViewSwitcher getSwitcher()
{
return mSwitcher;
}
public void goTo(Time time, boolean flag)
{
updateTitle(time);
MonthView monthview = (MonthView)mSwitcher.getCurrentView();
monthview.dismissPopup();
Time time1 = monthview.getTime();
if(flag)
{
int i = time1.month + 12 * time1.year;
MonthView monthview1;
if(time.month + 12 * time.year < i)
{
mSwitcher.setInAnimation(mInAnimationPast);
mSwitcher.setOutAnimation(mOutAnimationPast);
} else
{
mSwitcher.setInAnimation(mInAnimationFuture);
mSwitcher.setOutAnimation(mOutAnimationFuture);
}
}
monthview1 = (MonthView)mSwitcher.getNextView();
monthview1.setSelectionMode(monthview.getSelectionMode());
monthview1.setSelectedTime(time);
monthview1.reloadEvents();
setListview(monthview1.minLines());
monthview1.animationStarted();
mSwitcher.showNext();
monthview1.requestFocus();
mTime = time;
}
public void goToToday()
{
Time time = new Time(Utils.getTimeZone(this, mUpdateTZ));
time.set(System.currentTimeMillis());
time.minute = 0;
time.second = 0;
time.normalize(false);
((TextView)findViewById(0x7f0d0013)).setText(iphoneUtils.formatMonthYear(time));
mTime = time;
MonthView monthview = (MonthView)mSwitcher.getCurrentView();
monthview.setSelectedTime(time);
monthview.reloadEvents();
}
public View makeView()
{
MonthView monthview = new MonthView(this, this);
monthview.setLayoutParams(new android.widget.FrameLayout.LayoutParams(-1, -1));
monthview.setSelectedTime(mTime);
return monthview;
}
public void onAnimationEnd(Animation animation)
{
((MonthView)mSwitcher.getCurrentView()).animationFinished();
}
public void onAnimationRepeat(Animation animation)
{
}
public void onAnimationStart(Animation animation)
{
}
public void onClick(View view)
{
if(!view.equals(mTabAgenda)) goto _L2; else goto _L1
_L1:
iphoneUtils.startActivity(this, com/android/calendar/AgendaActivity.getName(), getSelectedTime());
iphoneUtils.cancelAnimationAndFinishActivity(this);
_L4:
return;
_L2:
if(view.equals(mTabDay))
{
iphoneUtils.startActivity(this, com/android/calendar/DayActivity.getName(), getSelectedTime());
iphoneUtils.cancelAnimationAndFinishActivity(this);
} else
if(view.equals(mButtonSetting))
iphoneUtils.startActivity(this, com/android/calendar/CalendarPreferenceActivity.getName(), getSelectedTime());
else
if(view.equals(mButtonAddEvent))
{
long l = getSelectedTime();
long l1 = l + 0x36ee80L;
Intent intent = new Intent("android.intent.action.EDIT");
intent.setClassName(this, com/android/calendar/EditEvent.getName());
intent.putExtra("beginTime", l);
intent.putExtra("endTime", l1);
intent.putExtra("allDay", getAllDay());
startActivity(intent);
overridePendingTransition(0x7f040000, 0x7f04000d);
} else
if(view.equals(mButtonToday))
goToToday();
if(true) goto _L4; else goto _L3
_L3:
}
protected void onCreate(Bundle bundle)
{
super.onCreate(bundle);
setRequestedOrientation(1);
setContentView(0x7f030019);
mContentResolver = getContentResolver();
long l;
int i;
String s;
String s1;
String s2;
String s3;
String s4;
String s5;
String s6;
if(bundle != null)
l = bundle.getLong("beginTime");
else
l = iphoneUtils.timeFromIntentInMillis(getIntent());
mTime = new Time(Utils.getTimeZone(this, mUpdateTZ));
mTime.set(l);
mTime.normalize(true);
mStartDay = Calendar.getInstance().getFirstDayOfWeek();
i = mStartDay - 1 - 1;
s = DateUtils.getDayOfWeekString(1 + (i + 1) % 7, 20);
((TextView)findViewById(0x7f0d00a7)).setText(s);
s1 = DateUtils.getDayOfWeekString(1 + (i + 2) % 7, 20);
((TextView)findViewById(0x7f0d00a8)).setText(s1);
s2 = DateUtils.getDayOfWeekString(1 + (i + 3) % 7, 20);
((TextView)findViewById(0x7f0d00a9)).setText(s2);
s3 = DateUtils.getDayOfWeekString(1 + (i + 4) % 7, 20);
((TextView)findViewById(0x7f0d00aa)).setText(s3);
s4 = DateUtils.getDayOfWeekString(1 + (i + 5) % 7, 20);
((TextView)findViewById(0x7f0d00ab)).setText(s4);
s5 = DateUtils.getDayOfWeekString(1 + (i + 6) % 7, 20);
((TextView)findViewById(0x7f0d00ac)).setText(s5);
s6 = DateUtils.getDayOfWeekString(1 + (i + 7) % 7, 20);
((TextView)findViewById(0x7f0d00ad)).setText(s6);
((TextView)findViewById(0x7f0d0013)).setText(iphoneUtils.formatMonthYear(mTime));
mEventLoader = new EventLoader(this);
mProgressBar = (ProgressBar)findViewById(0x7f0d0033);
mSwitcher = (ViewSwitcher)findViewById(0x7f0d0034);
mSwitcher.setFactory(this);
mSwitcher.getCurrentView().requestFocus();
mInAnimationPast = AnimationUtils.loadAnimation(this, 0x7f040004);
mOutAnimationPast = AnimationUtils.loadAnimation(this, 0x7f040005);
mInAnimationFuture = AnimationUtils.loadAnimation(this, 0x7f04000a);
mOutAnimationFuture = AnimationUtils.loadAnimation(this, 0x7f04000b);
mInAnimationPast.setAnimationListener(this);
mInAnimationFuture.setAnimationListener(this);
ll = (LinearLayout)findViewById(0x7f0d00ae);
mTabAgenda = (TextView)findViewById(0x7f0d000d);
mTabAgenda.setOnClickListener(this);
mTabDay = (TextView)findViewById(0x7f0d000e);
mTabDay.setOnClickListener(this);
mButtonSetting = (Button)findViewById(0x7f0d0002);
mButtonSetting.setOnClickListener(this);
mButtonAddEvent = (Button)findViewById(0x7f0d0004);
mButtonAddEvent.setOnClickListener(this);
mButtonToday = (Button)findViewById(0x7f0d000c);
mButtonToday.setOnClickListener(this);
}
public boolean onCreateOptionsMenu(Menu menu)
{
return super.onCreateOptionsMenu(menu);
}
protected void onNewIntent(Intent intent)
{
long l = iphoneUtils.timeFromIntentInMillis(intent);
if(l > 0L)
{
Time time = new Time(Utils.getTimeZone(this, mUpdateTZ));
time.set(l);
goTo(time, false);
}
}
public boolean onOptionsItemSelected(MenuItem menuitem)
{
return super.onOptionsItemSelected(menuitem);
}
protected void onPause()
{
super.onPause();
if(isFinishing())
mEventLoader.stopBackgroundThread();
mContentResolver.unregisterContentObserver(mObserver);
unregisterReceiver(mIntentReceiver);
((MonthView)mSwitcher.getCurrentView()).dismissPopup();
((MonthView)mSwitcher.getNextView()).dismissPopup();
mEventLoader.stopBackgroundThread();
CalendarApplication.setDefaultView(this, 0);
}
public boolean onPrepareOptionsMenu(Menu menu)
{
return super.onPrepareOptionsMenu(menu);
}
protected void onResume()
{
super.onResume();
mUpdateTZ.run();
mEventLoader.startBackgroundThread();
eventsChanged();
MonthView monthview = (MonthView)mSwitcher.getCurrentView();
MonthView monthview1 = (MonthView)mSwitcher.getNextView();
String s = PreferenceManager.getDefaultSharedPreferences(this).getString("preferredDetailedView", CalendarPreferenceActivity.DEFAULT_DETAILED_VIEW);
monthview.updateView();
monthview1.updateView();
monthview.setDetailedView(s);
monthview1.setDetailedView(s);
IntentFilter intentfilter = new IntentFilter();
intentfilter.addAction("android.intent.action.TIME_SET");
intentfilter.addAction("android.intent.action.DATE_CHANGED");
intentfilter.addAction("android.intent.action.TIMEZONE_CHANGED");
registerReceiver(mIntentReceiver, intentfilter);
setListview(monthview.minLines());
mContentResolver.registerContentObserver(android.provider.Calendar.Events.CONTENT_URI, true, mObserver);
}
protected void onSaveInstanceState(Bundle bundle)
{
super.onSaveInstanceState(bundle);
bundle.putLong("beginTime", mTime.toMillis(true));
}
public void setListview(int i)
{
lp = (android.widget.RelativeLayout.LayoutParams)ll.getLayoutParams();
newHeight = 110;
if(oldlines == i) goto _L2; else goto _L1
_L1:
if(i != 4) goto _L4; else goto _L3
_L3:
newHeight = 290;
_L6:
lp.height = newHeight;
if(oldHeight != 0)
{
TranslateAnimation translateanimation = new TranslateAnimation(0.0F, 0.0F, newHeight - oldHeight, 0.0F);
translateanimation.setDuration(400L);
ll.startAnimation(translateanimation);
}
oldlines = i;
oldHeight = newHeight;
_L2:
return;
_L4:
if(i == 5)
newHeight = 200;
else
if(i == 6)
newHeight = 110;
if(true) goto _L6; else goto _L5
_L5:
}
protected void startProgressSpinner()
{
mProgressBar.setVisibility(0);
}
protected void stopProgressSpinner()
{
mProgressBar.setVisibility(8);
}
public void updateTitle(Time time)
{
TextView textview = (TextView)findViewById(0x7f0d0013);
StringBuffer stringbuffer = new StringBuffer(iphoneUtils.formatMonthYear(time));
if(!TextUtils.equals(Utils.getTimeZone(this, mUpdateTZ), Time.getCurrentTimezone()))
{
int i = 1;
if(DateFormat.is24HourFormat(this))
i |= 0x80;
long l = System.currentTimeMillis();
String s = Utils.getTimeZone(this, mUpdateTZ);
boolean flag;
TimeZone timezone;
if(time.isDst != 0)
flag = true;
else
flag = false;
timezone = TimeZone.getTimeZone(s);
stringbuffer.append(" (").append(Utils.formatDateRange(this, l, l, i)).append(" ").append(timezone.getDisplayName(flag, 0, Locale.getDefault())).append(")");
}
textview.setText(stringbuffer.toString());
}
private static final boolean DEBUG = true;
private static final int INITIAL_HEAP_SIZE = 0x400000;
private static final String TAG = "MonthActivity";
private LinearLayout ll;
private android.widget.RelativeLayout.LayoutParams lp;
private Button mButtonAddEvent;
private Button mButtonSetting;
private Button mButtonToday;
private ContentResolver mContentResolver;
EventLoader mEventLoader;
private Animation mInAnimationFuture;
private Animation mInAnimationPast;
private BroadcastReceiver mIntentReceiver;
private ContentObserver mObserver;
private Animation mOutAnimationFuture;
private Animation mOutAnimationPast;
private ProgressBar mProgressBar;
private int mStartDay;
private ViewSwitcher mSwitcher;
private TextView mTabAgenda;
private TextView mTabDay;
private Time mTime;
private Runnable mUpdateTZ;
private int newHeight;
private int oldHeight;
private int oldlines;
private class _cls1
implements Runnable
{
public void run()
{
mTime.timezone = Utils.getTimeZone(MonthActivity.this, this);
mTime.normalize(true);
updateTitle(mTime);
}
final MonthActivity this$0;
_cls1()
{
this$0 = MonthActivity.this;
super();
}
}
private class _cls2 extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent)
{
String s = intent.getAction();
if(s.equals("android.intent.action.TIME_SET") || s.equals("android.intent.action.DATE_CHANGED") || s.equals("android.intent.action.TIMEZONE_CHANGED"))
eventsChanged();
}
final MonthActivity this$0;
_cls2()
{
this$0 = MonthActivity.this;
super();
}
}
private class _cls3 extends ContentObserver
{
public boolean deliverSelfNotifications()
{
return true;
}
public void onChange(boolean flag)
{
eventsChanged();
}
final MonthActivity this$0;
_cls3(Handler handler)
{
this$0 = MonthActivity.this;
super(handler);
}
}
}
UP:crying: :crying: :crying: :crying: :crying: :crying:

[Q] How to set as wallpaper the current image displayed in the ImageView ?

Hello guys
I am trying to build an application with 2 activities one is the main activity and the second activity which contain ImageView, and a 3 button’s. I want when I press the button to set as wallpaper the current image displayed in the ImageView . The problem is when I set the code for the Set Wallpaper button the first main activity is accessed without problems, but when I try to access the second activity the app crashes as you can see in the log. If I don’t configure the Set Wallpaper button, the code for the next and previous buttons runs smoothly. I tried several options and methods to configure the onClick for the Set Wallpaper button. Please help me with this problem. Here is my code:
Code:
public class Castles extends Activity {
protected static InputStream is;
public int currentImage = 0;
int[] imageIds = {
R.drawable.cas1,R.drawable.cas2,R.drawable.cas3,R.drawable.cas4,R.drawable.cas5,R.drawable.cas6,
R.drawable.cas7, R.drawable.cas8, R.drawable.cas9,R.drawable.cas10,R.drawable.cas11,R.drawable.cas12,
R.drawable.cas13,R.drawable.cas14,R.drawable.cas15,R.drawable.cas16, R.drawable.cas17,R.drawable.cas18,
R.drawable.cas19,R.drawable.cas20,R.drawable.cas21};
private Button BNatNext;
private Button BNatPri;
private Button BSetWallNat;
private ImageView IVNat;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.castles);
IVNat = (ImageView)findViewById(R.id.IVNat);
BNatNext=(Button)findViewById(R.id.BNatNext);
BNatPri=(Button)findViewById(R.id.BNatPri);
BNatNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
currentImage++;
currentImage=currentImage%imageIds.length;
IVNat.setImageResource(imageIds[currentImage]);
}
});
BNatPri.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
currentImage--;
currentImage=(currentImage+imageIds.length)%imageIds.length;
IVNat.setImageResource(imageIds[currentImage]);
}
});
BSetWallNat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
} catch(IOException e){
Log.e("Tag", "couldn't set wallpaper", e);
}
}
And this is the LogCat:
Code:
12-04 21:44:15.205: D/dalvikvm(1223): GC_EXTERNAL_ALLOC freed 44K, 51% free 2670K/5379K, external 1527K/1559K, paused 418ms
12-04 21:44:18.282: D/dalvikvm(1223): GC_EXTERNAL_ALLOC freed 1K, 51% free 2669K/5379K, external 4560K/5695K, paused 486ms
12-04 21:44:24.043: D/gralloc_goldfish(1223): Emulator without GPU emulation detected.
12-04 21:44:27.853: D/dalvikvm(1223): GC_EXTERNAL_ALLOC freed 11K, 50% free 2698K/5379K, external 7974K/7974K, paused 201ms
12-04 21:44:32.223: D/dalvikvm(1223): GC_EXTERNAL_ALLOC freed 2K, 50% free 2702K/5379K, external 11198K/11388K, paused 321ms
12-04 21:44:34.903: D/AndroidRuntime(1223): Shutting down VM
12-04 21:44:34.903: W/dalvikvm(1223): threadid=1: thread exiting with uncaught exception (group=0xb609d4f0)
12-04 21:44:34.963: E/AndroidRuntime(1223): FATAL EXCEPTION: main
12-04 21:44:34.963: E/AndroidRuntime(1223): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Roapps.wallpaperhd/com.Roapps.wallpaperhd.Castles}: java.lang.NullPointerException
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.os.Handler.dispatchMessage(Handler.java:99)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.os.Looper.loop(Looper.java:130)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-04 21:44:34.963: E/AndroidRuntime(1223): at java.lang.reflect.Method.invokeNative(Native Method)
12-04 21:44:34.963: E/AndroidRuntime(1223): at java.lang.reflect.Method.invoke(Method.java:507)
12-04 21:44:34.963: E/AndroidRuntime(1223): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-04 21:44:34.963: E/AndroidRuntime(1223): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-04 21:44:34.963: E/AndroidRuntime(1223): at dalvik.system.NativeStart.main(Native Method)
12-04 21:44:34.963: E/AndroidRuntime(1223): Caused by: java.lang.NullPointerException
12-04 21:44:34.963: E/AndroidRuntime(1223): at com.Roapps.wallpaperhd.Castles.onCreate(Castles.java:63)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-04 21:44:34.963: E/AndroidRuntime(1223): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-04 21:44:34.963: E/AndroidRuntime(1223): ... 11 more
12-04 21:44:38.963: I/Process(1223): Sending signal. PID: 1223 SIG: 9

Categories

Resources