public App() { currentApp = this; started = new StartEventHandler(() => { }); stopped = new StopEventHandler(() => { }); restarted = new RestartEventHandler(() => { }); authorized = new AuthorizedEventHandler(() => { }); stackSettingView = new List <View>(); activationLink = ""; InitializeComponent(); thisTabbedPage = new TabbedPage1(); thisTabbedPage.On <Xamarin.Forms.PlatformConfiguration.Android>().SetIsSwipePagingEnabled(true); MainPage = thisTabbedPage; //通知(App側で一括管理) DependencyService.Get <INotificationService>().Regist(); //すでに認証しているか確認 string aToken = ""; string aSecret = ""; string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + accessTokenFilePath; if (File.Exists(path)) { StreamReader readFile = new StreamReader(path, Encoding.GetEncoding("utf-16")); aToken = readFile.ReadLine(); aSecret = readFile.ReadLine(); readFile.Close(); t = CoreTweet.Tokens.Create(cKey, cSecret, aToken, aSecret); try { UserResponse result = t.Account.VerifyCredentials(); t.UserId = (long)result.Id; t.ScreenName = result.ScreenName; } catch (Exception) { t = null; } } if (t == null) { //認証していない場合は認証を行う。 (getContentPage("MainBrowser") as MainBrowser).web.authorizeAPI(cKey, cSecret); } else { (getContentPage("MainBrowser") as MainBrowser).web.twitterStart(); authorized(); } }
public static void registerRestartEvent(RestartEventHandler action) { currentApp.restarted += action; }