问题描述
我正在使用一个名为Timber&我一直在尝试向其添加启动画面,但没有运气.我将如何去做呢?
I am using an open source android project called Timber & I've been trying to add a splash screen to it but am having no luck. How would I go about doing it?
这是我的AndroidManifest:
Here my AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.technologx.blaze.player.pro"
android:installLocation="auto">
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyDhob3qPAx8Bj_bc1pUJW6lnGQUcbPPRmY" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<uses-sdk tools:overrideLibrary="de.Maxr1998.trackselectorlib" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="com.android.vending.BILLING" />
<application
android:name=".TimberApp"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme.FullScreen.Light"
tools:replace="android:allowBackup">
<activity
android:name="com.technologx.blaze.player.pro.SplashActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/TranslateThemeFull">
<activity
android:name=".activities.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.CATEGORY_APP_MUSIC" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" />
<data android:mimeType="audio/*" />
<data android:mimeType="application/ogg" />
<data android:mimeType="application/x-ogg" />
<data android:mimeType="application/itunes" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:mimeType="audio/*" />
<data android:mimeType="application/ogg" />
<data android:mimeType="application/x-ogg" />
<data android:mimeType="application/itunes" />
</intent-filter>
<intent-filter android:priority="-1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" />
<data android:mimeType="audio/*" />
<data android:mimeType="application/ogg" />
<data android:mimeType="application/x-ogg" />
<data android:mimeType="application/itunes" />
</intent-filter>
</activity>
</activity>
<activity
android:name=".activities.SettingsActivity"
android:theme="@style/AppThemeNormalLight" />
<activity
android:name=".activities.PlaylistDetailActivity"
android:theme="@style/AppTheme.FullScreen.Light" />
<activity
android:name=".activities.SearchActivity"
android:theme="@style/AppThemeNormalLight" />
<activity
android:name=".activities.NowPlayingActivity"
android:theme="@style/AppTheme.FullScreen.Light" />
<activity android:name=".activities.DonateActivity"/>
<receiver android:name=".helpers.MediaButtonIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="android.media.AUDIO_BECOMING_NOISY" />
</intent-filter>
</receiver>
<!-- Music service -->
<service
android:name=".MusicService"
android:label="@string/app_name"
android:process=":main" />
<service
android:name=".WearBrowserService"
android:exported="true">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<receiver android:name=".widgets.desktop.StandardWidget" android:label="@string/widget_standard">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.technologx.blaze.player.pro.metachanged" />
<action android:name="com.technologx.blaze.player.pro.playstatechanged" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_standard" />
</receiver>
<receiver android:name=".widgets.desktop.WhiteWidget" android:label="@string/widget_white">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.technologx.blaze.player.pro.metachanged" />
<action android:name="com.technologx.blaze.player.pro.playstatechanged" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_white" />
</receiver>
<receiver android:name=".widgets.desktop.SmallWidget" android:label="@string/widget_small">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.technologx.blaze.player.pro.metachanged" />
<action android:name="com.technologx.blaze.player.pro.playstatechanged" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_small" />
</receiver>
<meta-data
android:name="io.fabric.ApiKey"
android:value="296bae08d0c5c23efe01e9db11fd01e189ce666a" />
</application>
</manifest>
这是我的SplashActivity:
Here's my SplashActivity:
package com.technologx.blaze.player.pro;
/**
* Created by Technologx on 1/24/17.
*/
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import java.util.Random;
public class SplashActivity extends Activity {
private Animation mFadeIn;
private Animation mFadeInScale;
private Animation mFadeOut;
// @InjectView(R.id.image)
ImageView mImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
mImageView = (ImageView) findViewById(R.id.image);
int index = new Random().nextInt(2);
if (index == 1) {
mImageView.setImageResource(R.drawable.entrance3);
} else {
mImageView.setImageResource(R.drawable.entrance2);
}
initAnim();
setListener();
}
private void initAnim() {
mFadeIn = AnimationUtils.loadAnimation(this, R.anim.welcome_fade_in);
mFadeIn.setDuration(500);
mFadeInScale = AnimationUtils.loadAnimation(this,
R.anim.welcome_fade_in_scale);
mFadeInScale.setDuration(2000);
mFadeOut = AnimationUtils.loadAnimation(this, R.anim.welcome_fade_out);
mFadeOut.setDuration(500);
mImageView.startAnimation(mFadeIn);
}
public void setListener() {
mFadeIn.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
mImageView.startAnimation(mFadeInScale);
}
});
mFadeInScale.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
finish();
// mImageView.startAnimation(mFadeOut);
}
});
mFadeOut.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationEnd(Animation animation) {
// startActivity(MainActivity.class);
}
});
}
}
每次尝试生成签名的apk时,我都会遇到此错误.
Every time I try and generate a signed apk I run into this error.
我尝试将SplashActivity添加到清单中的几个不同区域,但是没有运气.我需要知道在AndroidManifest中的何处添加SplashActivity才能使其真正起作用吗?
I've tried adding the SplashActivity to several different areas in the manifest but have had no luck. I need to know where in the AndroidManifest to add the SplashActivity to actually get it to work?
推荐答案
检查您的活动标签
此功能尚未关闭
<activity
android:name="com.technologx.blaze.player.pro.SplashActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/TranslateThemeFull">
您需要以/>
或者...您需要向上移动这些关闭标签之一.
OR... you need to move one of these close tags up.
</activity>
</activity>
基本上,您不能再进行其他任何活动,因此WrongManifestParent
Basically, you can't have an activity in another one, hence WrongManifestParent
建议:撤消到可运行的状态,然后转到文件">新建">活动",它将为您正确触摸清单.
Suggestion: Undo to a state that is runnable, then go to File > New > Activity, and it'll touch the manifest correctly for you.
Sidenote: Timber
is a already an Android library
这篇关于启动画面活动-元素必须是元素[WrongManifestParent]的直接子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!