我正在使用一个按钮,它会将短信发送给固定号码。按下时我已经完成了代码但是当我合并
时<uses-permission android:name="android.permission.RECEIVE_SMS"/>
该应用无法启动。
01-16 21:13:56.211: I/zipro(1814): Found Zip archive, but it looks empty
01-16 21:13:56.211: D/asset(1814): failed to open Zip archive '/data/local/tmp/CaravanSmartApp.apk'
01-16 21:13:56.215: W/PackageParser(1814): Unable to read AndroidManifest.xml of /data/local/tmp/CaravanSmartApp.apk
01-16 21:13:56.215: W/PackageParser(1814): java.io.FileNotFoundException: AndroidManifest.xml
01-16 21:13:56.215: W/PackageParser(1814): at android.content.res.AssetManager.openXmlAssetNative(Native Method)
01-16 21:13:56.215: W/PackageParser(1814): at android.content.res.AssetManager.openXmlBlockAsset(AssetManager.java:488)
01-16 21:13:56.215: W/PackageParser(1814): at android.content.res.AssetManager.openXmlResourceParser(AssetManager.java:456)
01-16 21:13:56.215: W/PackageParser(1814): at android.content.pm.PackageParser.parsePackageLite(PackageParser.java:758)
01-16 21:13:56.215: W/PackageParser(1814): at com.android.defcontainer.DefaultContainerService$1.getMinimalPackageInfo(DefaultContainerService.java:173)
01-16 21:13:56.215: W/PackageParser(1814): at com.android.internal.app.IMediaContainerService$Stub.onTransact(IMediaContainerService.java:110)
01-16 21:13:56.215: W/PackageParser(1814): at android.os.Binder.execTransact(Binder.java:388)
01-16 21:13:56.215: W/PackageParser(1814): at dalvik.system.NativeStart.run(Native Method)
01-16 21:13:56.219: W/DefContainer(1814): Failed to parse package
01-16 21:13:56.219: W/ActivityManager(472): No content provider found for permission revoke: file:///data/local/tmp/CaravanSmartApp.apk
01-16 21:13:56.247: D/dalvikvm(472): GC_EXPLICIT freed 172K, 29% free 9573K/13364K, paused 3ms+1ms, total 28ms
01-16 21:13:56.251: D/AndroidRuntime(2767): Shutting down VM
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.caravansmartapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.example.gps3.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.osman.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false" >
</uses-feature>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBk7K5mdzkD8OJwGS8bvhLkmHJXxdxxxx" />
<activity
android:name="com.example.caravansmartapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.caravansmartapp.LocationActivity" />
<activity android:name="com.example.caravansmartapp.ContactActivity" />
<activity android:name="com.example.caravansmartapp.SMSActivity"/>
</application>
</manifest>
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onSOS(View view){
Intent intent = new Intent(this, SMSActivity.class);
startActivity(intent);
}
}
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class SMSActivity extends Activity{
Button buttonSend;
Intent intent;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String phoneNo = "9903070000";
String sms = "Hi...This is test";
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo,null,sms,null,null);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
finish();
}
}
}
请帮助!!!