0
我遇到了一個小問題(它可能沒有任何問題)。在Android應用程序中繼承應用程序
我有一個小的應用程序,它開始像這樣
namespace Paul.App
{
[Activity(Label = "@string/ApplicationName", MainLauncher = true, Theme = "@android:style/Theme.NoTitleBar",
ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait, Icon = "@drawable/icon")]
public class Paul : Application
{
public static Paul Application;
public Paul(IntPtr handle, JniHandleOwnership transfer) : base(handle, transfer)
{
在這個程序,我有
public Database dbm;
數據庫是做SQL事情
在這個命名空間中的一類,我也有一個OnCreate,它調用一個像這樣開始的新活動
namespace Paul.App.Splash
{
[Activity(Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true)]
public class Splash : Activity
{
protected override void OnCreate(Bundle bundle)
{
這很好,一切都很好。除了一件事。我無法實現數據庫的即時通訊!
如果我投入的OnCreate或保羅(IntPtr的...),並在使用其它活動
DBM =新DBManager();
飛濺開始,但如果我嘗試使用((Paul)Application)訪問dbm,它將返回null。
如果我這樣做,在飛濺的活動
((Paul)Application).dbm = new DBManager();
if (((Paul)Application).dbm.SetupDB() != false)
{
Toast.MakeText(this, "Database failed to initialise", ToastLength.Long);
return;
}
調試器告訴我,((保羅)是未知
這應該是一個簡單的事情 - 我想instantate SQLite的一次,然後用它整個應用程序。
這裏任何幫助,將不勝感激。
保羅