Skip to content

Commit

Permalink
#32 interacting with RPC with web3j
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1994 committed Oct 17, 2018
1 parent b2ace70 commit 9bb156d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


<application
android:name=".BlockerApplication"
android:largeHeap="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.example.choejun_yeong.blocker_android.R;
import com.example.choejun_yeong.blocker_android.fragment.login.LoginFragment;


public class LoginActivity extends AppCompatActivity{
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@


import android.Manifest;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.example.choejun_yeong.blocker_android.R;
import com.example.choejun_yeong.blocker_android.fragment.wallet.WalletFragment;
import com.gun0912.tedpermission.PermissionListener;
import com.gun0912.tedpermission.TedPermission;

import org.web3j.protocol.Web3j;
import org.web3j.protocol.Web3jFactory;
import org.web3j.protocol.core.methods.response.Web3ClientVersion;
import org.web3j.protocol.http.HttpService;

import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class WalletActivity extends AppCompatActivity {
@Override
Expand Down Expand Up @@ -45,5 +56,17 @@ public void onPermissionDenied(ArrayList<String> deniedPermissions) {
.setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE)
.check();

// web3
Web3j web3j = Web3jFactory.build(new HttpService("https://rinkeby.infura.io/v3/de770d2ce1834cc794cfd6dfe42fb83d"));
Web3ClientVersion web3ClientVersion = null;
try {
web3ClientVersion = web3j.web3ClientVersion().sendAsync().get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
String ClientVersionString = web3ClientVersion.getWeb3ClientVersion();
Toast.makeText(this, "Clientversion: " + ClientVersionString, Toast.LENGTH_SHORT).show();
}
}

0 comments on commit 9bb156d

Please sign in to comment.