public class MainActivity extends AppCompatActivity {
private static final String API_KEY = "b8fo0q33XyuCTm0qbr6XCg";
static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
static final JsonFactory JSON_FACTORY = new JacksonFactory();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button myBtn = (Button) findViewById(R.id.button);
TextView t=(TextView) findViewById(R.id.text);
}
public void onClick(View v) {
try {
CSApi api = new CSApi(
HTTP_TRANSPORT,
JSON_FACTORY,
API_KEY
);
CSPostConfig imageToPost = CSPostConfig.newBuilder()
.withRemoteImageUrl("https://questions4thoughts.files.wordpress.com/2008/11/50rupees.png")
.build();
CSPostResult portResult = api.postImage(imageToPost);
System.out.println("Post result: " + portResult);
try{
Thread.sleep(30000);
CSGetResult scoredResult = api.getImage(portResult);
// t.setText(scoredResult);
}
catch (InterruptedException e){
e.getCause();
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
i am new to this api. i have post and get files also i dont know how to use it. when i am running the app it says unfortunately stop. i have used cloudsight api but there no source for using it. Can u suggest some solution on how to use it or some other free api for image recognition.
Did you try giving internet permission above the application tag in Manifest.xml? if not, add the following line :