Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

34
LINES

< > BotCompany Repo | #1002653 // Android: Enter & save Slack token

JavaX source code (Android) [tags: use-pretranspiled] - run with: the app

Libraryless. Click here for Pure Java version (914L/6K/22K).

!752

import android.app.*;
import android.widget.*;
import android.view.*;
import android.view.View;
import android.view.KeyEvent;
import android.view.inputmethod.*;
import android.text.*;

m {
  static Activity androidContext;
  
  p {
    androidContext.runOnUiThread(runnable {
      final EditText et = new EditText(androidContext);
et.setSingleLine ();
      androidContext.setContentView(et);
      
      et.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
          if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
          
            S line = et.getText().toString().trim();
            saveSecretTextFile("slack-token.txt", line);
            
            Toast.makeText(androidContext, "Token saved!", Toast.LENGTH_SHORT).show();
          }
          return false;
        }
      });
    });
  }
}

Author comment

Began life as a copy of #1001079

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, nbgitpuheiab, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002653
Snippet name: Android: Enter & save Slack token
Eternal ID of this version: #1002653/1
Text MD5: 5ed102f6d0424f9fc5f140e11afce7a4
Transpilation MD5: f9fabef7ba898460052b8cb827464825
Author: stefan
Category: javax
Type: JavaX source code (Android)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-10 03:31:37
Source code size: 1014 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 583 / 1015
Referenced in: #1002613 - Test Slack RTM API 2 (using Tyrus)
#1002658 - Android Slack Hello
#3000382 - Answer for ferdie (>> t = 1, f = 0)