use of android.net.Uri in project cw-omnibus by commonsguy.
the class URLHandler method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView uri = (TextView) findViewById(R.id.uri);
if (Intent.ACTION_MAIN.equals(getIntent().getAction())) {
String intentUri = (new Intent("com.commonsware.android.MY_ACTION")).toUri(Intent.URI_INTENT_SCHEME).toString();
uri.setText(intentUri);
Log.w("URLHandler", intentUri);
} else {
Uri data = getIntent().getData();
if (data == null) {
uri.setText("Got com.commonsware.android.MY_ACTION Intent");
} else {
uri.setText(getIntent().getData().toString());
}
}
}
use of android.net.Uri in project cw-omnibus by commonsguy.
the class Provider method insert.
@Override
public Uri insert(Uri url, ContentValues initialValues) {
long rowID = db.insert(TABLE, Constants.TITLE, initialValues);
if (rowID > 0) {
Uri uri = ContentUris.withAppendedId(Provider.Constants.CONTENT_URI, rowID);
getContext().getContentResolver().notifyChange(uri, null);
return (uri);
}
throw new SQLException("Failed to insert row into " + url);
}
use of android.net.Uri in project materialistic by hidroh.
the class SubmitActivityTest method testSubmitError.
@Test
public void testSubmitError() {
((EditText) activity.findViewById(R.id.edittext_title)).setText("title");
((EditText) activity.findViewById(R.id.edittext_content)).setText("http://example.com");
shadowOf(activity).clickMenuItem(R.id.menu_send);
ShadowAlertDialog.getLatestAlertDialog().getButton(DialogInterface.BUTTON_POSITIVE).performClick();
verify(userServices).submit(any(Context.class), eq("title"), eq("http://example.com"), eq(true), submitCallback.capture());
Uri redirect = Uri.parse(BuildConfig.APPLICATION_ID + "://item?id=1234");
UserServices.Exception exception = new UserServices.Exception(R.string.item_exist);
exception.data = redirect;
submitCallback.getValue().onError(exception);
assertEquals(activity.getString(R.string.item_exist), ShadowToast.getTextOfLatestToast());
assertThat(shadowOf(activity).getNextStartedActivity()).hasAction(Intent.ACTION_VIEW).hasData(redirect);
}
use of android.net.Uri in project materialistic by hidroh.
the class FavoriteManagerTest method setUp.
@Before
public void setUp() {
resolver = shadowOf(RuntimeEnvironment.application.getContentResolver());
ContentValues cv = new ContentValues();
cv.put("itemid", "1");
cv.put("title", "title");
cv.put("url", "http://example.com");
cv.put("time", String.valueOf(System.currentTimeMillis()));
resolver.insert(MaterialisticProvider.URI_FAVORITE, cv);
cv = new ContentValues();
cv.put("itemid", "2");
cv.put("title", "ask HN");
cv.put("url", "http://example.com");
cv.put("time", String.valueOf(System.currentTimeMillis()));
resolver.insert(MaterialisticProvider.URI_FAVORITE, cv);
manager = new FavoriteManager(Schedulers.immediate()) {
@Override
protected Uri getUriForFile(Context context, File file) {
return Uri.parse("content://" + FavoriteManager.FILE_AUTHORITY + "/files/saved/materialistic-export.txt");
}
};
}
use of android.net.Uri in project AndroidTraining by mixi-inc.
the class TestTargetContentProvider method insert.
@Override
public Uri insert(Uri uri, ContentValues values) {
if (URI_MATCHER.match(uri) != TYPE_ITEMS) {
throw new IllegalArgumentException("unable to insert with this uri: " + uri);
}
SQLiteDatabase db = null;
try {
db = mDatabaseHelper.getWritableDatabase();
db.beginTransaction();
final long id = db.insertOrThrow("tests", null, values);
Uri newUri = ContentUris.withAppendedId(uri, id);
db.setTransactionSuccessful();
return newUri;
} finally {
if (db != null) {
db.endTransaction();
}
}
}
Aggregations