android问题:activity 跳转后不显示布局,只有空白
原来的receiver用intentpublicBroadcastReceiveronReceiver=newBroadcastReceiver(){publicvoid...
原来的receiver用 intent
public BroadcastReceiver onReceiver = new BroadcastReceiver(){
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals("android.intent.action.SCREEN_ON")){
Intent startIntent = new Intent(UnlockService.this, UnlockLayout.class);
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startIntent);
}
}
};
新的activity里的onCreate
public void onCreate() {
//super.onCreate(savedInstanceState);
setContentView(R.layout.unlock_main);
}
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.voiceunlock"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher" >
<activity
android:name="com.example.voiceunlock.MainActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
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.voiceunlock.UnlockLayout"
android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.SCREEN_ON"/>
</intent-filter>
</activity>
<receiver android:name=".UnlockReceiver" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="UnlockService"></service>
</application>
</manifest> 展开
public BroadcastReceiver onReceiver = new BroadcastReceiver(){
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals("android.intent.action.SCREEN_ON")){
Intent startIntent = new Intent(UnlockService.this, UnlockLayout.class);
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startIntent);
}
}
};
新的activity里的onCreate
public void onCreate() {
//super.onCreate(savedInstanceState);
setContentView(R.layout.unlock_main);
}
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.voiceunlock"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher" >
<activity
android:name="com.example.voiceunlock.MainActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
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.voiceunlock.UnlockLayout"
android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.SCREEN_ON"/>
</intent-filter>
</activity>
<receiver android:name=".UnlockReceiver" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service android:name="UnlockService"></service>
</application>
</manifest> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询