This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Intent; | |
import android.media.AudioManager; | |
import android.media.MediaPlayer; | |
import android.media.RingtoneManager; | |
import android.net.Uri; | |
import android.os.AsyncTask; | |
import android.os.Bundle; | |
import android.provider.MediaStore; | |
import android.support.v4.content.FileProvider; | |
import android.support.v7.app.AppCompatActivity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final String EXTRA_MESSAGE = "com.example.clarifaialarm.MESSAGE"; | |
public void setAlarm(View view) throws ParseException { | |
// Retrieve text editors | |
EditText date = findViewById(R.id.date); | |
EditText hour = findViewById(R.id.hour); | |
EditText minute = findViewById(R.id.minute); | |
EditText object = findViewById(R.id.object); | |
// Compile date-time for alarm to go off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<paths xmlns:android="http://schemas.android.com/apk/res/android"> | |
<files-path name="my_images" path="." /> | |
</paths> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<provider | |
android:name="android.support.v4.content.FileProvider" | |
android:authorities="com.example.clarifaialarm.fileprovider" | |
android:exported="false" | |
android:grantUriPermissions="true"> | |
<meta-data | |
android:name="android.support.FILE_PROVIDER_PATHS" | |
android:resource="@xml/file_paths" /> | |
</provider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
... | |
api 'com.clarifai.clarifai-api2:core:2.3.0' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-feature | |
android:name="android.hardware.camera" | |
android:required="true" /> | |
<uses-permission | |
android:name="android.permission.WRITE_EXTERNAL_STORAGE" | |
android:maxSdkVersion="18" /> | |
<uses-permission android:name="android.permission.INTERNET" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<string name="app_name">Clarifai Alarm</string> | |
<string name="button_text_alarm">Take Photo</string> | |
<string name="object_hint">Object to look for</string> | |
<string name="date_hint">Alarm date:YYYY-MM-DD</string> | |
<string name="hour_hint">Alarm Hour (24hr system)</string> | |
<string name="title_activity_alarm">AlarmActivity</string> | |
<string name="button_text_main">Set Alarm</string> | |
<string name="minute_hint">Alarm Minute</string> | |
<string name="info_text_default">Loading…</string> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class ClarifaiTask extends AsyncTask<File, Integer, Boolean> { | |
protected Boolean doInBackground(File... images) { | |
info.setText("Processing..."); | |
// Connect to Clarifai using your API token | |
ClarifaiClient client = new ClarifaiBuilder("YOUR_API_TOKEN").buildSync(); | |
List<ClarifaiOutput<Concept>> predictionResults; | |
// For each photo we pass, send it off to Clarifai | |
for (File image : images) { | |
predictionResults = client.getDefaultModels().generalModel().predict() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_alarm); | |
// Retrieve object to check for from initiating intent | |
object = getIntent().getStringExtra(MainActivity.EXTRA_MESSAGE); | |
info = findViewById(R.id.infoText); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onResume() { | |
super.onResume(); | |
// If we've taken a photo, send it off to Clarifai to check | |
if (photoPath != null) { | |
new ClarifaiTask().execute(new File(photoPath)); | |
} | |
} |
OlderNewer