的AndroidManifest.xml :
$string = mt_rand(100000, 999999);
$Message = 'Hi Dear, <br> Your Verification code is: <br> <h3>'.$string.'</h3> <br><br> Thanks';
$this->email->set_mailtype("html");
$config = array(
'protocol' => 'sendmail',
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->subject('Email Verification');
$this->email->message($Message);
$this->email->from('info@techeasesol.com','Kenswag');
$this->email->to($email);
$send = $this->email->send();
if($send)
{
$msg = "Please Check Your Email to Verify your Account";
$this->session->set_flashdata('success',$msg);
redirect('code-verify','refresh');
}
else
{
$msg = "Email Can't Send";
$this->session->set_flashdata('error',$msg);
redirect('Auth','refresh');
}
activity_splash_screen.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.saptarshi.railwayservices">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_train_black_24dp"
android:label="@string/app_name"
android:roundIcon="@drawable/ic_train_black_24dp"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".splashScreen"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Index"
android:label="@string/title_activity_index"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name=".pnrStatus" />
<activity android:name=".liveTrain" />
<activity android:name=".seatAvailability" />
</application>
</manifest>
splashScreen.java
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/launcher"
tools:context="com.example.saptarshi.railwayservices.splashScreen">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="229dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:src="@drawable/logo" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textAlignment="center"
android:textSize="25dp"
android:text="Railway Services"/>
</LinearLayout>
</LinearLayout>
现在,当我在手机上运行时,它显示在行的错误
splashScreen.java 中的import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class splashScreen extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
Intent intent = new Intent(getApplicationContext(), Index.class);
startActivity(intent);
finish();
}
}
。
但当我删除启动画面时,整个应用程序运行完美。我也用过线程来执行。但仍然显示错误:
java.lang.RuntimeException:无法启动活动 ComponentInfo {com.example.saptarshi.railwayservices / com.example.saptarshi.railwayservices.splashScreen}: java.lang.IllegalStateException:您需要使用Theme.AppCompat 这个活动的主题(或后代)。
答案 0 :(得分:0)
这是因为您不使用从Theme.AppCompat
派生的主题。在splashScreen
中,在向AndroidManifest.xml
添加以下属性时,您使用的是活动主题而不是AppCompatActivity主题:
android:theme="@android:style/Theme.NoTitleBar">
所以,你需要使用正确的。您可以使用:
android:theme="@style/AppTheme.NoActionBar">
然后,它应该是这样的:
<activity android:name=".splashScreen"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
注意:强>
如果您未将android:theme
添加到您的活动中,请执行以下操作:
<activity android:name=".pnrStatus" />
<activity android:name=".liveTrain" />
<activity android:name=".seatAvailability" />
这意味着该活动隐式使用了Application主题。在您的情况下,活动将使用android:theme="@style/AppTheme"
。这来自以下代码:
<application
android:allowBackup="true"
android:icon="@drawable/ic_train_black_24dp"
android:label="@string/app_name"
android:roundIcon="@drawable/ic_train_black_24dp"
android:supportsRtl="true"
android:theme="@style/AppTheme">
...
</application>