Example usage for android.net Uri getQueryParameter

List of usage examples for android.net Uri getQueryParameter

Introduction

In this page you can find the example usage for android.net Uri getQueryParameter.

Prototype

@Nullable
public String getQueryParameter(String key) 

Source Link

Document

Searches the query string for the first value with the given key.

Usage

From source file:de.vanita5.twittnuker.util.Utils.java

public static Fragment createFragmentForIntent(final Context context, final Intent intent) {
    final long start = System.currentTimeMillis();
    intent.setExtrasClassLoader(context.getClassLoader());
    final Bundle extras = intent.getExtras();
    final Uri uri = intent.getData();
    final Fragment fragment;
    if (uri == null)
        return null;
    final Bundle args = new Bundle();
    if (extras != null) {
        args.putAll(extras);/* w  w w  . j a v a  2s.  c om*/
    }
    switch (matchLinkId(uri)) {
    case LINK_ID_STATUS: {
        fragment = new StatusFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id));
        }
        break;
    }
    case LINK_ID_USER: {
        fragment = new UserProfileFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        break;
    }
    case LINK_ID_USER_LIST_MEMBERSHIPS: {
        fragment = new UserListMembershipsListFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        break;
    }
    case LINK_ID_USER_TIMELINE: {
        fragment = new UserTimelineFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        if (isEmpty(paramScreenName) && isEmpty(param_user_id))
            return null;
        break;
    }
    case LINK_ID_USER_FAVORITES: {
        fragment = new UserFavoritesFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (!args.containsKey(EXTRA_SCREEN_NAME) && !args.containsKey(EXTRA_USER_ID))
            return null;
        break;
    }
    case LINK_ID_USER_FOLLOWERS: {
        fragment = new UserFollowersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        if (isEmpty(paramScreenName) && isEmpty(param_user_id))
            return null;
        break;
    }
    case LINK_ID_USER_FRIENDS: {
        fragment = new UserFriendsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        if (isEmpty(paramScreenName) && isEmpty(param_user_id))
            return null;
        break;
    }
    case LINK_ID_USER_BLOCKS: {
        fragment = new UserBlocksListFragment();
        break;
    }
    case LINK_ID_MUTES_USERS: {
        fragment = new MutesUsersListFragment();
        break;
    }
    case LINK_ID_DIRECT_MESSAGES_CONVERSATION: {
        fragment = new DirectMessagesConversationFragment();
        final String paramRecipientId = uri.getQueryParameter(QUERY_PARAM_RECIPIENT_ID);
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final long conversationId = ParseUtils.parseLong(paramRecipientId);
        if (conversationId > 0) {
            args.putLong(EXTRA_RECIPIENT_ID, conversationId);
        } else if (paramScreenName != null) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        break;
    }
    case LINK_ID_USER_LIST: {
        fragment = new UserListDetailsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(param_list_id)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(param_user_id)))
            return null;
        args.putInt(EXTRA_LIST_ID, ParseUtils.parseInt(param_list_id));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LISTS: {
        fragment = new UserListsListFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        if (isEmpty(paramScreenName) && isEmpty(param_user_id))
            return null;
        break;
    }
    case LINK_ID_USER_LIST_TIMELINE: {
        fragment = new UserListTimelineFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(param_list_id)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(param_user_id)))
            return null;
        args.putInt(EXTRA_LIST_ID, ParseUtils.parseInt(param_list_id));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERS: {
        fragment = new UserListMembersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(param_list_id)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(param_user_id)))
            return null;
        args.putInt(EXTRA_LIST_ID, ParseUtils.parseInt(param_list_id));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LIST_SUBSCRIBERS: {
        fragment = new UserListSubscribersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(param_list_id)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(param_user_id)))
            return null;
        args.putInt(EXTRA_LIST_ID, ParseUtils.parseInt(param_list_id));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_SAVED_SEARCHES: {
        fragment = new SavedSearchesListFragment();
        break;
    }
    case LINK_ID_USER_MENTIONS: {
        fragment = new UserMentionsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        if (!args.containsKey(EXTRA_SCREEN_NAME) && !isEmpty(paramScreenName)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (isEmpty(args.getString(EXTRA_SCREEN_NAME)))
            return null;
        break;
    }
    case LINK_ID_INCOMING_FRIENDSHIPS: {
        fragment = new IncomingFriendshipsFragment();
        break;
    }
    case LINK_ID_USERS: {
        fragment = new UsersListFragment();
        break;
    }
    case LINK_ID_STATUSES: {
        fragment = new StatusesListFragment();
        break;
    }
    case LINK_ID_STATUS_RETWEETERS: {
        fragment = new StatusRetweetersListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id));
        }
        break;
    }
    case LINK_ID_STATUS_FAVORITERS: {
        fragment = new StatusFavoritersListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id));
        }
        break;
    }
    case LINK_ID_STATUS_REPLIES: {
        fragment = new StatusRepliesListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId));
        }
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        break;
    }
    case LINK_ID_SEARCH: {
        final String param_query = uri.getQueryParameter(QUERY_PARAM_QUERY);
        if (isEmpty(param_query))
            return null;
        args.putString(EXTRA_QUERY, param_query);
        fragment = new SearchFragment();
        break;
    }
    default: {
        return null;
    }
    }
    final String param_account_id = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID);
    if (param_account_id != null) {
        args.putLong(EXTRA_ACCOUNT_ID, ParseUtils.parseLong(param_account_id));
    } else {
        final String param_account_name = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_NAME);
        if (param_account_name != null) {
            args.putLong(EXTRA_ACCOUNT_ID, getAccountId(context, param_account_name));
        } else {
            final long account_id = getDefaultAccountId(context);
            if (isMyAccount(context, account_id)) {
                args.putLong(EXTRA_ACCOUNT_ID, account_id);
            }
        }
    }
    fragment.setArguments(args);
    if (isDebugBuild()) {
        Log.d(LOGTAG, String.format("createFragmentForIntent used %d ms", System.currentTimeMillis() - start));
    }
    return fragment;
}

From source file:org.getlantern.firetweet.util.Utils.java

public static Fragment createFragmentForIntent(final Context context, final int linkId, final Intent intent) {
    intent.setExtrasClassLoader(context.getClassLoader());
    final Bundle extras = intent.getExtras();
    final Uri uri = intent.getData();
    final Fragment fragment;
    if (uri == null)
        return null;
    final Bundle args = new Bundle();
    if (extras != null) {
        args.putAll(extras);// w  w  w. j  a v a2s.  c  om
    }
    switch (linkId) {
    case LINK_ID_STATUS: {
        fragment = new StatusFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id));
        }
        break;
    }
    case LINK_ID_USER: {
        fragment = new UserFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        break;
    }
    case LINK_ID_USER_LIST_MEMBERSHIPS: {
        fragment = new UserListMembershipsListFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        break;
    }
    case LINK_ID_USER_TIMELINE: {
        fragment = new UserTimelineFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (isEmpty(paramScreenName) && isEmpty(paramUserId))
            return null;
        break;
    }
    case LINK_ID_USER_MEDIA_TIMELINE: {
        fragment = new UserMediaTimelineFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (isEmpty(paramScreenName) && isEmpty(paramUserId))
            return null;
        break;
    }
    case LINK_ID_USER_FAVORITES: {
        fragment = new UserFavoritesFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (!args.containsKey(EXTRA_SCREEN_NAME) && !args.containsKey(EXTRA_USER_ID))
            return null;
        break;
    }
    case LINK_ID_USER_FOLLOWERS: {
        fragment = new UserFollowersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        if (isEmpty(paramScreenName) && isEmpty(param_user_id))
            return null;
        break;
    }
    case LINK_ID_USER_FRIENDS: {
        fragment = new UserFriendsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id));
        }
        if (isEmpty(paramScreenName) && isEmpty(param_user_id))
            return null;
        break;
    }
    case LINK_ID_USER_BLOCKS: {
        fragment = new UserBlocksListFragment();
        break;
    }
    case LINK_ID_MUTES_USERS: {
        fragment = new MutesUsersListFragment();
        break;
    }
    case LINK_ID_DIRECT_MESSAGES_CONVERSATION: {
        fragment = new MessagesConversationFragment();
        final String paramRecipientId = uri.getQueryParameter(QUERY_PARAM_RECIPIENT_ID);
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final long conversationId = ParseUtils.parseLong(paramRecipientId);
        if (conversationId > 0) {
            args.putLong(EXTRA_RECIPIENT_ID, conversationId);
        } else if (paramScreenName != null) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        break;
    }
    case LINK_ID_USER_LIST: {
        fragment = new UserListFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(paramListId)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId)))
            return null;
        args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LISTS: {
        fragment = new UserListsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (!args.containsKey(EXTRA_USER_ID)) {
            args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        }
        if (isEmpty(paramScreenName) && isEmpty(paramUserId))
            return null;
        break;
    }
    case LINK_ID_USER_LIST_TIMELINE: {
        fragment = new UserListTimelineFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(paramListId)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId)))
            return null;
        args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LIST_MEMBERS: {
        fragment = new UserListMembersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(paramListId)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId)))
            return null;
        args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_USER_LIST_SUBSCRIBERS: {
        fragment = new UserListSubscribersFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID);
        final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID);
        final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME);
        if (isEmpty(paramListId)
                && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId)))
            return null;
        args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId));
        args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId));
        args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        args.putString(EXTRA_LIST_NAME, paramListName);
        break;
    }
    case LINK_ID_SAVED_SEARCHES: {
        fragment = new SavedSearchesListFragment();
        break;
    }
    case LINK_ID_USER_MENTIONS: {
        fragment = new UserMentionsFragment();
        final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
        if (!args.containsKey(EXTRA_SCREEN_NAME) && !isEmpty(paramScreenName)) {
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        if (isEmpty(args.getString(EXTRA_SCREEN_NAME)))
            return null;
        break;
    }
    case LINK_ID_INCOMING_FRIENDSHIPS: {
        fragment = new IncomingFriendshipsFragment();
        break;
    }
    case LINK_ID_USERS: {
        fragment = new UsersListFragment();
        break;
    }
    case LINK_ID_STATUSES: {
        fragment = new StatusesListFragment();
        break;
    }
    case LINK_ID_STATUS_RETWEETERS: {
        fragment = new StatusRetweetersListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId));
        }
        break;
    }
    case LINK_ID_STATUS_FAVORITERS: {
        fragment = new StatusFavoritersListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId));
        }
        break;
    }
    case LINK_ID_STATUS_REPLIES: {
        fragment = new StatusRepliesListFragment();
        if (!args.containsKey(EXTRA_STATUS_ID)) {
            final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID);
            args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId));
        }
        if (!args.containsKey(EXTRA_SCREEN_NAME)) {
            final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME);
            args.putString(EXTRA_SCREEN_NAME, paramScreenName);
        }
        break;
    }
    case LINK_ID_SEARCH: {
        final String param_query = uri.getQueryParameter(QUERY_PARAM_QUERY);
        if (isEmpty(param_query))
            return null;
        args.putString(EXTRA_QUERY, param_query);
        fragment = new SearchFragment();
        break;
    }
    default: {
        return null;
    }
    }
    final String paramAccountId = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID);
    if (paramAccountId != null) {
        args.putLong(EXTRA_ACCOUNT_ID, ParseUtils.parseLong(paramAccountId));
    } else {
        final String paramAccountName = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_NAME);
        if (paramAccountName != null) {
            args.putLong(EXTRA_ACCOUNT_ID, getAccountId(context, paramAccountName));
        } else {
            final long accountId = getDefaultAccountId(context);
            if (isMyAccount(context, accountId)) {
                args.putLong(EXTRA_ACCOUNT_ID, accountId);
            }
        }
    }
    fragment.setArguments(args);
    return fragment;
}

From source file:cgeo.geocaching.CacheDetailActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, R.layout.cachedetail_activity);

    // get parameters
    final Bundle extras = getIntent().getExtras();
    final Uri uri = AndroidBeam.getUri(getIntent());

    // try to get data from extras
    String name = null;/*w w  w. j a v a 2  s .co m*/
    String guid = null;

    if (extras != null) {
        geocode = extras.getString(Intents.EXTRA_GEOCODE);
        name = extras.getString(Intents.EXTRA_NAME);
        guid = extras.getString(Intents.EXTRA_GUID);
    }

    // When clicking a cache in MapsWithMe, we get back a PendingIntent
    if (StringUtils.isEmpty(geocode)) {
        geocode = MapsMeCacheListApp.getCacheFromMapsWithMe(this, getIntent());
    }

    if (geocode == null && uri != null) {
        geocode = ConnectorFactory.getGeocodeFromURL(uri.toString());
    }

    // try to get data from URI
    if (geocode == null && guid == null && uri != null) {
        final String uriHost = uri.getHost().toLowerCase(Locale.US);
        final String uriPath = uri.getPath().toLowerCase(Locale.US);
        final String uriQuery = uri.getQuery();

        if (uriQuery != null) {
            Log.i("Opening URI: " + uriHost + uriPath + "?" + uriQuery);
        } else {
            Log.i("Opening URI: " + uriHost + uriPath);
        }

        if (uriHost.contains("geocaching.com")) {
            if (StringUtils.startsWith(uriPath, "/geocache/gc")) {
                geocode = StringUtils.substringBefore(uriPath.substring(10), "_").toUpperCase(Locale.US);
            } else {
                geocode = uri.getQueryParameter("wp");
                guid = uri.getQueryParameter("guid");

                if (StringUtils.isNotBlank(geocode)) {
                    geocode = geocode.toUpperCase(Locale.US);
                    guid = null;
                } else if (StringUtils.isNotBlank(guid)) {
                    geocode = null;
                    guid = guid.toLowerCase(Locale.US);
                } else {
                    showToast(res.getString(R.string.err_detail_open));
                    finish();
                    return;
                }
            }
        }
    }

    // no given data
    if (geocode == null && guid == null) {
        showToast(res.getString(R.string.err_detail_cache));
        finish();
        return;
    }

    // If we open this cache from a search, let's properly initialize the title bar, even if we don't have cache details
    setCacheTitleBar(geocode, name, null);

    final LoadCacheHandler loadCacheHandler = new LoadCacheHandler(this, progress);

    try {
        String title = res.getString(R.string.cache);
        if (StringUtils.isNotBlank(name)) {
            title = name;
        } else if (geocode != null && StringUtils.isNotBlank(geocode)) { // can't be null, but the compiler doesn't understand StringUtils.isNotBlank()
            title = geocode;
        }
        progress.show(this, title, res.getString(R.string.cache_dialog_loading_details), true,
                loadCacheHandler.disposeMessage());
    } catch (final RuntimeException ignored) {
        // nothing, we lost the window
    }

    final int pageToOpen = savedInstanceState != null ? savedInstanceState.getInt(STATE_PAGE_INDEX, 0)
            : Settings.isOpenLastDetailsPage() ? Settings.getLastDetailsPage() : 1;
    createViewPager(pageToOpen, new OnPageSelectedListener() {

        @Override
        public void onPageSelected(final int position) {
            if (Settings.isOpenLastDetailsPage()) {
                Settings.setLastDetailsPage(position);
            }
            // lazy loading of cache images
            if (getPage(position) == Page.IMAGES) {
                loadCacheImages();
            }
            requireGeodata = getPage(position) == Page.DETAILS;
            startOrStopGeoDataListener(false);

            // dispose contextual actions on page change
            if (currentActionMode != null) {
                currentActionMode.finish();
            }
        }
    });
    requireGeodata = pageToOpen == 1;

    final String realGeocode = geocode;
    final String realGuid = guid;
    AndroidRxUtils.networkScheduler.scheduleDirect(new Runnable() {
        @Override
        public void run() {
            search = Geocache.searchByGeocode(realGeocode, StringUtils.isBlank(realGeocode) ? realGuid : null,
                    false, loadCacheHandler);
            loadCacheHandler.sendMessage(Message.obtain());
        }
    });

    // Load Generic Trackables
    if (StringUtils.isNotBlank(geocode)) {
        AndroidRxUtils.bindActivity(this,
                // Obtain the active connectors and load trackables in parallel.
                Observable.fromIterable(ConnectorFactory.getGenericTrackablesConnectors())
                        .flatMap(new Function<TrackableConnector, Observable<Trackable>>() {
                            @Override
                            public Observable<Trackable> apply(final TrackableConnector trackableConnector) {
                                processedBrands.add(trackableConnector.getBrand());
                                return Observable.defer(new Callable<Observable<Trackable>>() {
                                    @Override
                                    public Observable<Trackable> call() {
                                        return Observable
                                                .fromIterable(trackableConnector.searchTrackables(geocode));
                                    }
                                }).subscribeOn(AndroidRxUtils.networkScheduler);
                            }
                        }).toList())
                .subscribe(new Consumer<List<Trackable>>() {
                    @Override
                    public void accept(final List<Trackable> trackables) {
                        // Todo: this is not really a good method, it may lead to duplicates ; ie: in OC connectors.
                        // Store trackables.
                        genericTrackables.addAll(trackables);
                        if (!trackables.isEmpty()) {
                            // Update the UI if any trackables were found.
                            notifyDataSetChanged();
                        }
                    }
                });
    }

    locationUpdater = new CacheDetailsGeoDirHandler(this);

    // If we have a newer Android device setup Android Beam for easy cache sharing
    AndroidBeam.enable(this, this);
}

From source file:org.cafemember.ui.LaunchActivity.java

private boolean handleIntent(Intent intent, boolean isNew, boolean restore, boolean fromPassword) {
    int flags = intent.getFlags();
    if (!fromPassword && (AndroidUtilities.needShowPasscode(true) || UserConfig.isWaitingForPasscodeEnter)) {
        showPasscodeActivity();//  w  ww . j  ava 2 s  .com
        passcodeSaveIntent = intent;
        passcodeSaveIntentIsNew = isNew;
        passcodeSaveIntentIsRestore = restore;
        UserConfig.saveConfig(false);
    } else {
        boolean pushOpened = false;

        Integer push_user_id = 0;
        Integer push_chat_id = 0;
        Integer push_enc_id = 0;
        Integer open_settings = 0;
        long dialogId = intent != null && intent.getExtras() != null ? intent.getExtras().getLong("dialogId", 0)
                : 0;
        boolean showDialogsList = false;
        boolean showPlayer = false;

        photoPathsArray = null;
        videoPath = null;
        sendingText = null;
        documentsPathsArray = null;
        documentsOriginalPathsArray = null;
        documentsMimeType = null;
        documentsUrisArray = null;
        contactsToSend = null;

        if (UserConfig.isClientActivated() && (flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
            if (intent != null && intent.getAction() != null && !restore) {
                if (Intent.ACTION_SEND.equals(intent.getAction())) {
                    boolean error = false;
                    String type = intent.getType();
                    if (type != null && type.equals(ContactsContract.Contacts.CONTENT_VCARD_TYPE)) {
                        try {
                            Uri uri = (Uri) intent.getExtras().get(Intent.EXTRA_STREAM);
                            if (uri != null) {
                                ContentResolver cr = getContentResolver();
                                InputStream stream = cr.openInputStream(uri);

                                String name = null;
                                String nameEncoding = null;
                                String nameCharset = null;
                                ArrayList<String> phones = new ArrayList<>();
                                BufferedReader bufferedReader = new BufferedReader(
                                        new InputStreamReader(stream, "UTF-8"));
                                String line;
                                while ((line = bufferedReader.readLine()) != null) {
                                    String[] args = line.split(":");
                                    if (args.length != 2) {
                                        continue;
                                    }
                                    if (args[0].startsWith("FN")) {
                                        String[] params = args[0].split(";");
                                        for (String param : params) {
                                            String[] args2 = param.split("=");
                                            if (args2.length != 2) {
                                                continue;
                                            }
                                            if (args2[0].equals("CHARSET")) {
                                                nameCharset = args2[1];
                                            } else if (args2[0].equals("ENCODING")) {
                                                nameEncoding = args2[1];
                                            }
                                        }
                                        name = args[1];
                                        if (nameEncoding != null
                                                && nameEncoding.equalsIgnoreCase("QUOTED-PRINTABLE")) {
                                            while (name.endsWith("=") && nameEncoding != null) {
                                                name = name.substring(0, name.length() - 1);
                                                line = bufferedReader.readLine();
                                                if (line == null) {
                                                    break;
                                                }
                                                name += line;
                                            }
                                            byte[] bytes = AndroidUtilities
                                                    .decodeQuotedPrintable(name.getBytes());
                                            if (bytes != null && bytes.length != 0) {
                                                String decodedName = new String(bytes, nameCharset);
                                                if (decodedName != null) {
                                                    name = decodedName;
                                                }
                                            }
                                        }
                                    } else if (args[0].startsWith("TEL")) {
                                        String phone = PhoneFormat.stripExceptNumbers(args[1], true);
                                        if (phone.length() > 0) {
                                            phones.add(phone);
                                        }
                                    }
                                }
                                try {
                                    bufferedReader.close();
                                    stream.close();
                                } catch (Exception e) {
                                    FileLog.e("tmessages", e);
                                }
                                if (name != null && !phones.isEmpty()) {
                                    contactsToSend = new ArrayList<>();
                                    for (String phone : phones) {
                                        TLRPC.User user = new TLRPC.TL_userContact_old2();
                                        user.phone = phone;
                                        user.first_name = name;
                                        user.last_name = "";
                                        user.id = 0;
                                        contactsToSend.add(user);
                                    }
                                }
                            } else {
                                error = true;
                            }
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                            error = true;
                        }
                    } else {
                        String text = intent.getStringExtra(Intent.EXTRA_TEXT);
                        if (text == null) {
                            CharSequence textSequence = intent.getCharSequenceExtra(Intent.EXTRA_TEXT);
                            if (textSequence != null) {
                                text = textSequence.toString();
                            }
                        }
                        String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);

                        if (text != null && text.length() != 0) {
                            if ((text.startsWith("http://") || text.startsWith("https://")) && subject != null
                                    && subject.length() != 0) {
                                text = subject + "\n" + text;
                            }
                            sendingText = text;
                        } else if (subject != null && subject.length() > 0) {
                            sendingText = subject;
                        }

                        Parcelable parcelable = intent.getParcelableExtra(Intent.EXTRA_STREAM);
                        if (parcelable != null) {
                            String path;
                            if (!(parcelable instanceof Uri)) {
                                parcelable = Uri.parse(parcelable.toString());
                            }
                            Uri uri = (Uri) parcelable;
                            if (uri != null) {
                                if (isInternalUri(uri)) {
                                    error = true;
                                }
                            }
                            if (!error) {
                                if (uri != null && (type != null && type.startsWith("image/")
                                        || uri.toString().toLowerCase().endsWith(".jpg"))) {
                                    if (photoPathsArray == null) {
                                        photoPathsArray = new ArrayList<>();
                                    }
                                    photoPathsArray.add(uri);
                                } else {
                                    path = AndroidUtilities.getPath(uri);
                                    if (path != null) {
                                        if (path.startsWith("file:")) {
                                            path = path.replace("file://", "");
                                        }
                                        if (type != null && type.startsWith("video/")) {
                                            videoPath = path;
                                        } else {
                                            if (documentsPathsArray == null) {
                                                documentsPathsArray = new ArrayList<>();
                                                documentsOriginalPathsArray = new ArrayList<>();
                                            }
                                            documentsPathsArray.add(path);
                                            documentsOriginalPathsArray.add(uri.toString());
                                        }
                                    } else {
                                        if (documentsUrisArray == null) {
                                            documentsUrisArray = new ArrayList<>();
                                        }
                                        documentsUrisArray.add(uri);
                                        documentsMimeType = type;
                                    }
                                }
                                if (sendingText != null) {
                                    if (sendingText.contains("WhatsApp")) { //remove unnecessary caption 'sent from WhatsApp' from photos forwarded from WhatsApp
                                        sendingText = null;
                                    }
                                }
                            }
                        } else if (sendingText == null) {
                            error = true;
                        }
                    }
                    if (error) {
                        Toast.makeText(this, "Unsupported content", Toast.LENGTH_SHORT).show();
                    }
                } else if (intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
                    boolean error = false;
                    try {
                        ArrayList<Parcelable> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
                        String type = intent.getType();
                        if (uris != null) {
                            for (int a = 0; a < uris.size(); a++) {
                                Parcelable parcelable = uris.get(a);
                                if (!(parcelable instanceof Uri)) {
                                    parcelable = Uri.parse(parcelable.toString());
                                }
                                Uri uri = (Uri) parcelable;
                                if (uri != null) {
                                    if (isInternalUri(uri)) {
                                        uris.remove(a);
                                        a--;
                                    }
                                }
                            }
                            if (uris.isEmpty()) {
                                uris = null;
                            }
                        }
                        if (uris != null) {
                            if (type != null && type.startsWith("image/")) {
                                for (int a = 0; a < uris.size(); a++) {
                                    Parcelable parcelable = uris.get(a);
                                    if (!(parcelable instanceof Uri)) {
                                        parcelable = Uri.parse(parcelable.toString());
                                    }
                                    Uri uri = (Uri) parcelable;
                                    if (photoPathsArray == null) {
                                        photoPathsArray = new ArrayList<>();
                                    }
                                    photoPathsArray.add(uri);
                                }
                            } else {
                                for (int a = 0; a < uris.size(); a++) {
                                    Parcelable parcelable = uris.get(a);
                                    if (!(parcelable instanceof Uri)) {
                                        parcelable = Uri.parse(parcelable.toString());
                                    }
                                    String path = AndroidUtilities.getPath((Uri) parcelable);
                                    String originalPath = parcelable.toString();
                                    if (originalPath == null) {
                                        originalPath = path;
                                    }
                                    if (path != null) {
                                        if (path.startsWith("file:")) {
                                            path = path.replace("file://", "");
                                        }
                                        if (documentsPathsArray == null) {
                                            documentsPathsArray = new ArrayList<>();
                                            documentsOriginalPathsArray = new ArrayList<>();
                                        }
                                        documentsPathsArray.add(path);
                                        documentsOriginalPathsArray.add(originalPath);
                                    }
                                }
                            }
                        } else {
                            error = true;
                        }
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                        error = true;
                    }
                    if (error) {
                        Toast.makeText(this, "Unsupported content", Toast.LENGTH_SHORT).show();
                    }
                } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
                    Uri data = intent.getData();
                    if (data != null) {
                        String username = null;
                        String group = null;
                        String sticker = null;
                        String botUser = null;
                        String botChat = null;
                        String message = null;
                        Integer messageId = null;
                        boolean hasUrl = false;
                        String scheme = data.getScheme();
                        if (scheme != null) {
                            if ((scheme.equals("http") || scheme.equals("https"))) {
                                String host = data.getHost().toLowerCase();
                                if (host.equals("telegram.me") || host.equals("telegram.dog")) {
                                    String path = data.getPath();
                                    if (path != null && path.length() > 1) {
                                        path = path.substring(1);
                                        if (path.startsWith("joinchat/")) {
                                            group = path.replace("joinchat/", "");
                                        } else if (path.startsWith("addstickers/")) {
                                            sticker = path.replace("addstickers/", "");
                                        } else if (path.startsWith("msg/") || path.startsWith("share/")) {
                                            message = data.getQueryParameter("url");
                                            if (message == null) {
                                                message = "";
                                            }
                                            if (data.getQueryParameter("text") != null) {
                                                if (message.length() > 0) {
                                                    hasUrl = true;
                                                    message += "\n";
                                                }
                                                message += data.getQueryParameter("text");
                                            }
                                        } else if (path.length() >= 1) {
                                            List<String> segments = data.getPathSegments();
                                            if (segments.size() > 0) {
                                                username = segments.get(0);
                                                if (segments.size() > 1) {
                                                    messageId = Utilities.parseInt(segments.get(1));
                                                    if (messageId == 0) {
                                                        messageId = null;
                                                    }
                                                }
                                            }
                                            botUser = data.getQueryParameter("start");
                                            botChat = data.getQueryParameter("startgroup");
                                        }
                                    }
                                }
                            } else if (scheme.equals("tg")) {
                                String url = data.toString();
                                if (url.startsWith("tg:resolve") || url.startsWith("tg://resolve")) {
                                    url = url.replace("tg:resolve", "tg://telegram.org").replace("tg://resolve",
                                            "tg://telegram.org");
                                    data = Uri.parse(url);
                                    username = data.getQueryParameter("domain");
                                    botUser = data.getQueryParameter("start");
                                    botChat = data.getQueryParameter("startgroup");
                                } else if (url.startsWith("tg:join") || url.startsWith("tg://join")) {
                                    url = url.replace("tg:join", "tg://telegram.org").replace("tg://join",
                                            "tg://telegram.org");
                                    data = Uri.parse(url);
                                    group = data.getQueryParameter("invite");
                                } else if (url.startsWith("tg:addstickers")
                                        || url.startsWith("tg://addstickers")) {
                                    url = url.replace("tg:addstickers", "tg://telegram.org")
                                            .replace("tg://addstickers", "tg://telegram.org");
                                    data = Uri.parse(url);
                                    sticker = data.getQueryParameter("set");
                                } else if (url.startsWith("tg:msg") || url.startsWith("tg://msg")
                                        || url.startsWith("tg://share") || url.startsWith("tg:share")) {
                                    url = url.replace("tg:msg", "tg://telegram.org")
                                            .replace("tg://msg", "tg://telegram.org")
                                            .replace("tg://share", "tg://telegram.org")
                                            .replace("tg:share", "tg://telegram.org");
                                    data = Uri.parse(url);
                                    message = data.getQueryParameter("url");
                                    if (message == null) {
                                        message = "";
                                    }
                                    if (data.getQueryParameter("text") != null) {
                                        if (message.length() > 0) {
                                            hasUrl = true;
                                            message += "\n";
                                        }
                                        message += data.getQueryParameter("text");
                                    }
                                }
                            }
                        }
                        if (username != null || group != null || sticker != null || message != null) {
                            runLinkRequest(username, group, sticker, botUser, botChat, message, hasUrl,
                                    messageId, 0);
                        } else {
                            try {
                                Cursor cursor = getContentResolver().query(intent.getData(), null, null, null,
                                        null);
                                if (cursor != null) {
                                    if (cursor.moveToFirst()) {
                                        int userId = cursor.getInt(cursor.getColumnIndex("DATA4"));
                                        NotificationCenter.getInstance()
                                                .postNotificationName(NotificationCenter.closeChats);
                                        push_user_id = userId;
                                    }
                                    cursor.close();
                                }
                            } catch (Exception e) {
                                FileLog.e("tmessages", e);
                            }
                        }
                    }
                } else if (intent.getAction().equals("org.telegram.messenger.OPEN_ACCOUNT")) {
                    open_settings = 1;
                } else if (intent.getAction().startsWith("com.tmessages.openchat")) {
                    int chatId = intent.getIntExtra("chatId", 0);
                    int userId = intent.getIntExtra("userId", 0);
                    int encId = intent.getIntExtra("encId", 0);
                    if (chatId != 0) {
                        NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
                        push_chat_id = chatId;
                    } else if (userId != 0) {
                        NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
                        push_user_id = userId;
                    } else if (encId != 0) {
                        NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
                        push_enc_id = encId;
                    } else {
                        showDialogsList = true;
                    }
                } else if (intent.getAction().equals("com.tmessages.openplayer")) {
                    showPlayer = true;
                }
            }
        }

        if (push_user_id != 0) {
            Bundle args = new Bundle();
            args.putInt("user_id", push_user_id);
            if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args,
                    mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
                ChatActivity fragment = new ChatActivity(args);
                if (actionBarLayout.presentFragment(fragment, false, true, true)) {
                    pushOpened = true;
                }
            }
        } else if (push_chat_id != 0) {
            Bundle args = new Bundle();
            args.putInt("chat_id", push_chat_id);
            if (mainFragmentsStack.isEmpty() || MessagesController.checkCanOpenChat(args,
                    mainFragmentsStack.get(mainFragmentsStack.size() - 1))) {
                ChatActivity fragment = new ChatActivity(args);
                if (actionBarLayout.presentFragment(fragment, false, true, true)) {
                    pushOpened = true;
                }
            }
        } else if (push_enc_id != 0) {
            Bundle args = new Bundle();
            args.putInt("enc_id", push_enc_id);
            ChatActivity fragment = new ChatActivity(args);
            if (actionBarLayout.presentFragment(fragment, false, true, true)) {
                pushOpened = true;
            }
        } else if (showDialogsList) {
            if (!AndroidUtilities.isTablet()) {
                actionBarLayout.removeAllFragments();
            } else {
                if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
                    for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
                        layersActionBarLayout
                                .removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
                        a--;
                    }
                    layersActionBarLayout.closeLastFragment(false);
                }
            }
            pushOpened = false;
            isNew = false;
        } else if (showPlayer) {
            if (AndroidUtilities.isTablet()) {
                for (int a = 0; a < layersActionBarLayout.fragmentsStack.size(); a++) {
                    BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(a);
                    if (fragment instanceof AudioPlayerActivity) {
                        layersActionBarLayout.removeFragmentFromStack(fragment);
                        break;
                    }
                }
                actionBarLayout.showLastFragment();
                rightActionBarLayout.showLastFragment();
                drawerLayoutContainer.setAllowOpenDrawer(false, false);
            } else {
                for (int a = 0; a < actionBarLayout.fragmentsStack.size(); a++) {
                    BaseFragment fragment = actionBarLayout.fragmentsStack.get(a);
                    if (fragment instanceof AudioPlayerActivity) {
                        actionBarLayout.removeFragmentFromStack(fragment);
                        break;
                    }
                }
                drawerLayoutContainer.setAllowOpenDrawer(true, false);
            }
            actionBarLayout.presentFragment(new AudioPlayerActivity(), false, true, true);
            pushOpened = true;
        } else if (videoPath != null || photoPathsArray != null || sendingText != null
                || documentsPathsArray != null || contactsToSend != null || documentsUrisArray != null) {
            if (!AndroidUtilities.isTablet()) {
                NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
            }
            if (dialogId == 0) {
                Bundle args = new Bundle();
                args.putBoolean("onlySelect", true);
                if (contactsToSend != null) {
                    args.putString("selectAlertString",
                            LocaleController.getString("SendContactTo", R.string.SendMessagesTo));
                    args.putString("selectAlertStringGroup",
                            LocaleController.getString("SendContactToGroup", R.string.SendContactToGroup));
                } else {
                    args.putString("selectAlertString",
                            LocaleController.getString("SendMessagesTo", R.string.SendMessagesTo));
                    args.putString("selectAlertStringGroup",
                            LocaleController.getString("SendMessagesToGroup", R.string.SendMessagesToGroup));
                }
                DialogsActivity fragment = new DialogsActivity(args);
                dialogsFragment = fragment;
                fragment.setDelegate(this);
                boolean removeLast;
                if (AndroidUtilities.isTablet()) {
                    removeLast = layersActionBarLayout.fragmentsStack.size() > 0
                            && layersActionBarLayout.fragmentsStack.get(
                                    layersActionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
                } else {
                    removeLast = actionBarLayout.fragmentsStack.size() > 1 && actionBarLayout.fragmentsStack
                            .get(actionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
                }
                actionBarLayout.presentFragment(fragment, removeLast, true, true);
                pushOpened = true;
                if (PhotoViewer.getInstance().isVisible()) {
                    PhotoViewer.getInstance().closePhoto(false, true);
                }

                drawerLayoutContainer.setAllowOpenDrawer(false, false);
                if (AndroidUtilities.isTablet()) {
                    actionBarLayout.showLastFragment();
                    rightActionBarLayout.showLastFragment();
                } else {
                    drawerLayoutContainer.setAllowOpenDrawer(true, false);
                }
            } else {
                didSelectDialog(null, dialogId, false);
            }
        } else if (open_settings != 0) {
            actionBarLayout.presentFragment(new SettingsActivity(), false, true, true);
            if (AndroidUtilities.isTablet()) {
                actionBarLayout.showLastFragment();
                rightActionBarLayout.showLastFragment();
                drawerLayoutContainer.setAllowOpenDrawer(false, false);
            } else {
                drawerLayoutContainer.setAllowOpenDrawer(true, false);
            }
            pushOpened = true;
        }

        if (!pushOpened && !isNew) {
            if (AndroidUtilities.isTablet()) {
                if (!UserConfig.isClientActivated()) {
                    if (layersActionBarLayout.fragmentsStack.isEmpty()) {
                        layersActionBarLayout.addFragmentToStack(new LoginActivity());
                        drawerLayoutContainer.setAllowOpenDrawer(false, false);
                    }
                } else {
                    if (actionBarLayout.fragmentsStack.isEmpty()) {
                        actionBarLayout.addFragmentToStack(new DialogsActivity(null));
                        drawerLayoutContainer.setAllowOpenDrawer(true, false);
                    }
                }
            } else {
                if (actionBarLayout.fragmentsStack.isEmpty()) {
                    if (!UserConfig.isClientActivated()) {
                        actionBarLayout.addFragmentToStack(new LoginActivity());
                        drawerLayoutContainer.setAllowOpenDrawer(false, false);
                    } else {
                        actionBarLayout.addFragmentToStack(new DialogsActivity(null));
                        drawerLayoutContainer.setAllowOpenDrawer(true, false);
                    }
                }
            }
            actionBarLayout.showLastFragment();
            if (AndroidUtilities.isTablet()) {
                layersActionBarLayout.showLastFragment();
                rightActionBarLayout.showLastFragment();
            }
        }

        intent.setAction(null);
        return pushOpened;
    }
    return false;
}

From source file:com.ludoscity.findmybikes.activities.NearbyActivity.java

@Override
public void onStationMapFragmentInteraction(final Uri uri) {
    //Will be warned of station details click, will make info fragment to replace list fragment

    //Map ready//from  w  ww .  j  a v  a  2 s . c  om
    if (uri.getPath().equalsIgnoreCase("/" + StationMapFragment.MAP_READY_PATH)) {
        long wishedUpdateTime = DBHelper.getLastUpdateTimestamp(getApplicationContext())
                + NearbyActivity.this.getApplicationContext().getResources()
                        .getInteger(R.integer.update_auto_interval_minute) * 1000 * 60; //comes from Prefs

        if (mDownloadWebTask == null && !( //if no download task been launched but conditions are met that one will be launched imminently, don't refresh map
        DBHelper.getAutoUpdate(this) && System.currentTimeMillis() >= wishedUpdateTime
                && Utils.Connectivity.isConnected(this)))
            refreshMap();
    }
    //Marker click - ignored if onboarding is in progress
    else if (uri.getPath().equalsIgnoreCase("/" + StationMapFragment.MARKER_CLICK_PATH)
            && mOnboardingShowcaseView == null) {

        if (!isLookingForBike() || mStationMapFragment.getMarkerBVisibleLatLng() != null) {

            if (isLookingForBike()) {

                if (getListPagerAdapter().highlightStationForPage(
                        uri.getQueryParameter(StationMapFragment.MARKER_CLICK_TITLE_PARAM),
                        StationListPagerAdapter.BIKE_STATIONS)) {

                    getListPagerAdapter().smoothScrollHighlightedInViewForPage(
                            StationListPagerAdapter.BIKE_STATIONS, isAppBarExpanded());

                    mStationMapFragment.setPinOnStation(true,
                            uri.getQueryParameter(StationMapFragment.MARKER_CLICK_TITLE_PARAM));
                    getListPagerAdapter().setupBTabStationARecap(getListPagerAdapter()
                            .getHighlightedStationForPage(StationListPagerAdapter.BIKE_STATIONS),
                            mDataOutdated);

                    if (mStationMapFragment.getMarkerBVisibleLatLng() != null) {
                        LatLng newALatLng = mStationMapFragment.getMarkerALatLng();
                        getListPagerAdapter().notifyStationAUpdate(newALatLng, mCurrentUserLatLng);
                        hideSetupShowTripDetailsWidget();

                        if ((getListPagerAdapter().getClosestBikeLatLng().latitude != newALatLng.latitude)
                                && (getListPagerAdapter()
                                        .getClosestBikeLatLng().longitude != newALatLng.longitude)) {

                            mStationMapFragment.setMapPaddingRight(
                                    (int) getResources().getDimension(R.dimen.map_fab_padding));
                            mAutoSelectBikeFab.show();
                            animateCameraToShowUserAndStation(getListPagerAdapter()
                                    .getHighlightedStationForPage(StationListPagerAdapter.BIKE_STATIONS));

                        }
                    }
                }
            } else {

                if (mAppBarLayout != null)
                    mAppBarLayout.setExpanded(false, true);

                //B Tab, looking for dock
                final String clickedStationId = uri
                        .getQueryParameter(StationMapFragment.MARKER_CLICK_TITLE_PARAM);
                setupBTabSelection(clickedStationId, false);

                boolean showFavoriteAddFab = false;

                if (!mStationMapFragment.isPickedFavoriteMarkerVisible()) {
                    if (mStationMapFragment.isPickedPlaceMarkerVisible())
                        showFavoriteAddFab = true; //Don't setup the fab as it's been done in OnActivityResult
                    else if (setupAddFavoriteFab(new FavoriteItemStation(clickedStationId,
                            getStation(clickedStationId).getName(), true)))
                        showFavoriteAddFab = true;
                }

                if (showFavoriteAddFab)
                    mAddFavoriteFAB.show();
                else
                    mAddFavoriteFAB.hide();
            }
        } else {

            Utils.Snackbar.makeStyled(mCoordinatorLayout, R.string.onboarding_hint_main_choice,
                    Snackbar.LENGTH_SHORT, ContextCompat.getColor(this, R.color.theme_primary_dark)).show();

            mStationListViewPager.setCurrentItem(StationListPagerAdapter.DOCK_STATIONS, true);
        }
    }
}

From source file:com.android.contacts.common.model.ContactBuilder.java

public Contact build() {
    if (mName == null) {
        throw new IllegalStateException("Name has not been set");
    }//  w  w  w . jav a  2  s. c o m
    Uri lookupUri = null;

    if (mDirectoryType != FORWARD_LOOKUP && mDirectoryType != PEOPLE_LOOKUP
            && mDirectoryType != REVERSE_LOOKUP) {
        throw new IllegalStateException("Invalid directory type");
    }

    final ContentValues values = new ContentValues();
    values.put(ContactsContract.Data._ID, -1);
    final RawContact rawContact = new RawContact(values);

    final ContentValues numberValues = new ContentValues();
    numberValues.put(ContactsContract.Data._ID, -1);
    numberValues.put(ContactsContract.Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);

    // Use the incoming call's phone number if no other phone number
    // is specified. The reverse lookup source could present the phone
    // number differently (eg. without the area code).
    if (mPhoneNumbers.size() == 0) {
        PhoneNumber pn = new PhoneNumber();
        // Use the formatted number where possible
        pn.number = mFormattedNumber != null ? mFormattedNumber : mNormalizedNumber;
        pn.type = Phone.TYPE_MAIN;
        numberValues.put(ContactsContract.Data.DATA1, pn.number);
        addPhoneNumber(pn);
    }

    try {
        JSONObject contact = new JSONObject();

        // Insert the name
        contact.put(StructuredName.CONTENT_ITEM_TYPE, mName.getJsonObject());

        final String dataKeyPrefix = "data";

        // Insert phone numbers
        JSONArray phoneNumbers = new JSONArray();
        for (int i = 0; i < mPhoneNumbers.size(); i++) {
            phoneNumbers.put(mPhoneNumbers.get(i).getJsonObject());
            if (i + 1 < 15) { // data14 is max
                numberValues.put(dataKeyPrefix + (i + 1), mPhoneNumbers.get(i).number);
            }
        }
        rawContact.addDataItemValues(numberValues);
        contact.put(Phone.CONTENT_ITEM_TYPE, phoneNumbers);

        final ContentValues addressValues = new ContentValues();
        addressValues.put(ContactsContract.Data._ID, -1);
        addressValues.put(ContactsContract.Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE);

        // Insert addresses if there are any
        if (mAddresses.size() > 0) {
            JSONArray addresses = new JSONArray();
            for (int i = 0; i < mAddresses.size(); i++) {
                addresses.put(mAddresses.get(i).getJsonObject());
                if (i + 1 < 15) { // data14 is max
                    addressValues.put(dataKeyPrefix + (i + 1), mAddresses.get(i).formattedAddress);
                }
            }
            contact.put(StructuredPostal.CONTENT_ITEM_TYPE, addresses);
            rawContact.addDataItemValues(addressValues);
        }

        // Insert websites if there are any
        if (mWebsites.size() > 0) {
            JSONArray websites = new JSONArray();
            for (int i = 0; i < mWebsites.size(); i++) {
                websites.put(mWebsites.get(i).getJsonObject());
            }
            contact.put(Website.CONTENT_ITEM_TYPE, websites);
        }

        // add spam count and attribution
        contact.put(CallerMetaData.SPAM_COUNT, getSpamCount());
        contact.put(CallerMetaData.INFO_PROVIDER, getInfoProviderName());
        contact.put(CallerMetaData.SUCCINCT_LOCATION, getSuccinctLocation());
        contact.put(CallerMetaData.PHOTO_URL, getPhotoUrl());
        mPhotoUrl = getPhotoUrl();

        String json = new JSONObject().put(Contacts.DISPLAY_NAME, mName.displayName)
                .put(Contacts.DISPLAY_NAME_SOURCE, mDisplayNameSource)
                .put(Directory.EXPORT_SUPPORT, Directory.EXPORT_SUPPORT_ANY_ACCOUNT)
                .put(Contacts.CONTENT_ITEM_TYPE, contact).toString();

        if (json != null) {
            long directoryId = -1;
            switch (mDirectoryType) {
            case FORWARD_LOOKUP:
                directoryId = DirectoryId.NEARBY;
                break;
            case PEOPLE_LOOKUP:
                directoryId = DirectoryId.PEOPLE;
                break;
            case REVERSE_LOOKUP:
                // use null directory to be backwards compatible with old code
                directoryId = DirectoryId.NULL;
                break;
            }

            lookupUri = Contacts.CONTENT_LOOKUP_URI.buildUpon().appendPath(Constants.LOOKUP_URI_ENCODED)
                    .appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId))
                    .encodedFragment(json).build();
        }

        final Contact contactToReturn = new Contact(lookupUri, lookupUri, lookupUri, mDirectoryId,
                null /* lookupKey */, -1 /* id */, -1 /* nameRawContactId */, mDisplayNameSource,
                0 /* photoId */, mPhotoUrl, mName.displayName, mName.givenName,
                mName.phoneticGivenName /* phoneticName */, false /* starred */, null /* presence */,
                false /* sendToVoicemail */, null /* customRingtone */, false /* isUserProfile */);

        contactToReturn.setStatuses(new ImmutableMap.Builder<Long, DataStatus>().build());
        final String accountName = contact.optString(ContactsContract.RawContacts.ACCOUNT_NAME, null);
        final String directoryName = lookupUri.getQueryParameter(Directory.DISPLAY_NAME);
        if (accountName != null) {
            final String accountType = contact.getString(ContactsContract.RawContacts.ACCOUNT_TYPE);
            contactToReturn.setDirectoryMetaData(directoryName, null, accountName, accountType,
                    contact.optInt(Directory.EXPORT_SUPPORT, Directory.EXPORT_SUPPORT_SAME_ACCOUNT_ONLY));
        } else {
            contactToReturn.setDirectoryMetaData(directoryName, null, null, null,
                    contact.optInt(Directory.EXPORT_SUPPORT, Directory.EXPORT_SUPPORT_ANY_ACCOUNT));
        }

        final ContentValues nameValues = new ContentValues();
        nameValues.put(ContactsContract.Data._ID, -1);
        nameValues.put(ContactsContract.Data.DATA1, mName.displayName);
        nameValues.put(ContactsContract.Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
        rawContact.addDataItemValues(nameValues);

        contactToReturn.setRawContacts(new ImmutableList.Builder<RawContact>().add(rawContact).build());

        contactToReturn.setSpamCount(getSpamCount());
        contactToReturn.setProviderName(getInfoProviderName());

        return contactToReturn;
    } catch (JSONException e) {
        Log.e(TAG, "Failed to build contactToReturn", e);
        return null;
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

@SuppressLint("NewApi")
@Override/*ww w.j a v a2  s . co  m*/
public void onResume() {
    // if (Navit.METHOD_DEBUG) Navit.my_func_name(0);

    // System.gc();
    super.onResume();

    //      // --- alive timestamp ---
    //      app_status_lastalive = System.currentTimeMillis();
    //      System.out.println("app_status_string set:[onResume]:app_status_lastalive=" + app_status_lastalive);
    //      PreferenceManager.getDefaultSharedPreferences(this).edit().putLong(PREF_KEY_LASTALIVE, app_status_lastalive).commit();
    //      // --- alive timestamp ---

    // hide main progress bar ------------
    if (Navit.progressbar_main_activity.getVisibility() == View.VISIBLE) {
        Navit.progressbar_main_activity.setProgress(0);
        Navit.progressbar_main_activity.setVisibility(View.GONE);
    }
    // hide main progress bar ------------

    try {
        sensorManager.registerListener(lightSensorEventListener, lightSensor, (int) (8 * 1000000)); // updates approx. every 8 seconds
    } catch (Exception e) {
    }

    // get the intent fresh !! ----------
    startup_intent = this.getIntent();
    // get the intent fresh !! ----------

    // ------------- get all the flags for intro pages -------------
    // ------------- get all the flags for intro pages -------------
    // ------------- get all the flags for intro pages -------------
    try {
        intro_flag_nomaps = false;
        if (!have_maps_installed()) {
            if ((!NavitMapDownloader.download_active) && (!NavitMapDownloader.download_active_start)) {
                intro_flag_nomaps = true;
            }
        }
    } catch (Exception e) {
    }

    try {
        intro_flag_indexmissing = false;
        allow_use_index_search();
        if (Navit_index_on_but_no_idx_files) {
            if (!NavitMapDownloader.download_active_start) {
                intro_flag_indexmissing = true;
            }
        }

    } catch (Exception e) {
    }

    intro_flag_firststart = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PREF_KEY_FIRST_START,
            true);
    if (intro_flag_firststart) {
        intro_flag_update = false;
    }

    if (EasyPermissions.hasPermissions(this, perms)) {
        // have permissions!
        intro_flag_permissions = false;
    } else {
        // ask for permissions
        intro_flag_permissions = true;
    }

    // only show in onCreate() ------
    //      if (intro_show_count > 0)
    //      {
    //         intro_flag_info = false;
    //         intro_flag_firststart = false;
    //         intro_flag_update = false;
    //      }
    // only show in onCreate() ------

    // ------------- get all the flags for intro pages -------------
    // ------------- get all the flags for intro pages -------------
    // ------------- get all the flags for intro pages -------------

    // -------------- INTRO --------------
    // -------------- INTRO --------------
    // -------------- INTRO --------------
    if (Navit.CIDEBUG == 0) // -MAT-INTRO-
    {
        //         intro_flag_nomaps = true;
        //         intro_flag_info = true;
        //         intro_flag_firststart = false;
        //         intro_flag_update = false;
        //         intro_flag_indexmissing = false;
        //        intro_flag_crash = true;

        if (intro_flag_crash || intro_flag_firststart || intro_flag_indexmissing || intro_flag_info
                || intro_flag_nomaps || intro_flag_permissions || intro_flag_update) {

            System.out.println("flags=" + "intro_flag_crash:" + intro_flag_crash + " intro_flag_firststart:"
                    + intro_flag_firststart + " intro_flag_indexmissing:" + intro_flag_indexmissing
                    + " intro_flag_info:" + intro_flag_info + " intro_flag_nomaps:" + intro_flag_nomaps
                    + " intro_flag_permissions:" + intro_flag_permissions + " intro_flag_update:"
                    + intro_flag_update);

            // intro pages
            System.out.println("ZANaviMainIntroActivity:" + "start count=" + intro_show_count);
            intro_show_count++;
            Intent intent = new Intent(this, ZANaviMainIntroActivityStatic.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivityForResult(intent, ZANaviIntro_id);
        }
    }
    //      // -------------- INTRO --------------
    //      // -------------- INTRO --------------
    //      // -------------- INTRO --------------

    PackageInfo pkgInfo;
    Navit_Plugin_001_Installed = false;
    try {
        // is the donate version installed?
        pkgInfo = getPackageManager().getPackageInfo("com.zoffcc.applications.zanavi_msg", 0);
        String sharedUserId = pkgInfo.sharedUserId;
        System.out.println("str nd=" + sharedUserId);
        if (sharedUserId.equals("com.zoffcc.applications.zanavi")) {
            System.out.println("##plugin 001##");
            Navit_Plugin_001_Installed = true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----

    try {
        System.out.println("XXIIXX:111");
        String mid_str = this.getIntent().getExtras().getString("com.zoffcc.applications.zanavi.mid");
        System.out.println("XXIIXX:111a:mid_str=" + mid_str);

        if (mid_str != null) {
            if (mid_str.equals("201:UPDATE-APP")) {
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
                // a new ZANavi version is available, show something to the user here -------------------
            } else if (mid_str.startsWith("202:UPDATE-MAP:")) {
                System.out.println("need to update1:" + mid_str);
                System.out.println("need to update2:" + mid_str.substring(15));

                auto_start_update_map(mid_str.substring(15));
            }
        }

        System.out.println("XXIIXX:111b:mid_str=" + mid_str);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("XXIIXX:111:EEEE");
    }

    try {
        System.out.println("XXIIXX:" + this.getIntent());
        Bundle bundle77 = this.getIntent().getExtras();
        System.out.println("XXIIXX:" + intent_flags_to_string(this.getIntent().getFlags()));
        if (bundle77 == null) {
            System.out.println("XXIIXX:" + "null");
        } else {
            for (String key : bundle77.keySet()) {
                Object value = bundle77.get(key);
                System.out.println("XXIIXX:"
                        + String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()));
            }
        }
    } catch (Exception ee22) {
        String exst = Log.getStackTraceString(ee22);
        System.out.println("XXIIXX:ERR:" + exst);
    }
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----
    // ---- Intent dump ----

    is_paused = false;

    Navit_doubleBackToExitPressedOnce = false;

    app_window = getWindow();

    Log.e("Navit", "OnResume");

    while (Global_Init_Finished == 0) {
        Log.e("Navit", "OnResume:Global_Init_Finished==0 !!!!!");
        try {
            Thread.sleep(30, 0); // sleep
        } catch (InterruptedException e) {
        }
    }

    //InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    cwthr.NavitActivity2(1);

    try {
        NSp.resume_me();
    } catch (Exception e) {
        e.printStackTrace();
    }

    NavitVehicle.turn_on_sat_status();

    try {
        if (wl != null) {
            //            try
            //            {
            //               wl.release();
            //            }
            //            catch (Exception e2)
            //            {
            //            }
            wl.acquire();
            Log.e("Navit", "WakeLock: acquire 2");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    //Intent caller = this.getIntent();
    //System.out.println("A=" + caller.getAction() + " D=" + caller.getDataString());
    //System.out.println("C=" + caller.getComponent().flattenToString());

    if (unsupported) {
        class CustomListener implements View.OnClickListener {
            private final Dialog dialog;

            public CustomListener(Dialog dialog) {
                this.dialog = dialog;
            }

            @Override
            public void onClick(View v) {

                // Do whatever you want here

                // If you want to close the dialog, uncomment the line below
                //dialog.dismiss();
            }
        }

        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setTitle("WeltBild Tablet");
        dialog.setCancelable(false);
        dialog.setMessage("Your device is not supported!");
        dialog.show();
        //Button theButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
        //theButton.setOnClickListener(new CustomListener(dialog));
    }

    // reset "maps too old" flag
    Navit_maps_too_old = false;

    if (Navit_maps_loaded == false) {
        Navit_maps_loaded = true;
        // activate all maps
        Log.e("Navit", "**** LOAD ALL MAPS **** start");
        Message msg3 = new Message();
        Bundle b3 = new Bundle();
        b3.putInt("Callback", 20);
        msg3.setData(b3);
        NavitGraphics.callback_handler.sendMessage(msg3);
        Log.e("Navit", "**** LOAD ALL MAPS **** end");
    }

    try {
        NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);

        //         if (!have_maps_installed())
        //         {
        //            // System.out.println("MMMM=no maps installed");
        //            // show semi transparent box "no maps installed" ------------------
        //            // show semi transparent box "no maps installed" ------------------
        //            NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
        //            try
        //            {
        //               NavitGraphics.no_maps_container.setActivated(true);
        //            }
        //            catch (NoSuchMethodError e)
        //            {
        //            }
        //
        //            show_case_001();
        //
        //            // show semi transparent box "no maps installed" ------------------
        //            // show semi transparent box "no maps installed" ------------------
        //         }
        //         else
        //         {
        //            NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
        //            try
        //            {
        //               NavitGraphics.no_maps_container.setActivated(false);
        //            }
        //            catch (NoSuchMethodError e)
        //            {
        //            }
        //         }
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        // draw map no-async
        Message msg = new Message();
        Bundle b = new Bundle();
        b.putInt("Callback", 64);
        msg.setData(b);
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
        e.printStackTrace();
    }

    String intent_data = null;
    try {
        //Log.e("Navit", "**9**A " + startup_intent.getAction());
        //Log.e("Navit", "**9**D " + startup_intent.getDataString());

        int type = 1; // default = assume it's a map coords intent

        try {
            String si = startup_intent.getDataString();
            String tmp2 = si.split(":", 2)[0];
            Log.e("Navit", "**9a**A " + startup_intent.getAction());
            Log.e("Navit", "**9a**D " + startup_intent.getDataString() + " " + tmp2);
            if (tmp2.equals("file")) {
                Log.e("Navit", "**9b**D " + startup_intent.getDataString() + " " + tmp2);
                if (si.toLowerCase().endsWith(".gpx")) {
                    Log.e("Navit", "**9c**D " + startup_intent.getDataString() + " " + tmp2);
                    type = 4;
                }
            }
        } catch (Exception e2) {
        }

        if (type != 4) {
            Bundle extras = startup_intent.getExtras();
            // System.out.println("DH:001");
            if (extras != null) {
                // System.out.println("DH:002");
                long l = extras.getLong("com.zoffcc.applications.zanavi.ZANAVI_INTENT_type");
                // System.out.println("DH:003 l=" + l);
                if (l != 0L) {
                    // System.out.println("DH:004");
                    if (l == Navit.NAVIT_START_INTENT_DRIVE_HOME) {
                        // System.out.println("DH:005");
                        type = 2; // call from drive-home-widget
                    }
                    // ok, now remove that key
                    extras.remove("com.zoffcc.applications.zanavi");
                    startup_intent.replaceExtras((Bundle) null);
                    // System.out.println("DH:006");
                }
            }
        }

        // ------------------------  BIG LOOP  ------------------------
        // ------------------------  BIG LOOP  ------------------------
        if (type == 2) {
            // drive home

            // check if we have a home location
            int home_id = find_home_point();

            if (home_id != -1) {
                Message msg7 = progress_handler.obtainMessage();
                Bundle b7 = new Bundle();
                msg7.what = 2; // long Toast message
                b7.putString("text", Navit.get_text("driving to Home Location")); //TRANS
                msg7.setData(b7);
                progress_handler.sendMessage(msg7);

                // clear any previous destinations
                Message msg2 = new Message();
                Bundle b2 = new Bundle();
                b2.putInt("Callback", 7);
                msg2.setData(b2);
                NavitGraphics.callback_handler.sendMessage(msg2);

                // set position to middle of screen -----------------------
                // set position to middle of screen -----------------------
                // set position to middle of screen -----------------------
                //               Message msg67 = new Message();
                //               Bundle b67 = new Bundle();
                //               b67.putInt("Callback", 51);
                //               b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
                //               b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
                //               msg67.setData(b67);
                //               N_NavitGraphics.callback_handler.sendMessage(msg67);
                // set position to middle of screen -----------------------
                // set position to middle of screen -----------------------
                // set position to middle of screen -----------------------

                try {
                    Thread.sleep(60);
                } catch (Exception e) {
                }

                Navit.destination_set();

                // set destination to home location
                //               String lat = String.valueOf(map_points.get(home_id).lat);
                //               String lon = String.valueOf(map_points.get(home_id).lon);
                //               String q = map_points.get(home_id).point_name;
                route_wrapper(map_points.get(home_id).point_name, 0, 0, false, map_points.get(home_id).lat,
                        map_points.get(home_id).lon, true);

                final Thread zoom_to_route_001 = new Thread() {
                    int wait = 1;
                    int count = 0;
                    int max_count = 60;

                    @Override
                    public void run() {
                        while (wait == 1) {
                            try {
                                if ((NavitGraphics.navit_route_status == 17)
                                        || (NavitGraphics.navit_route_status == 33)) {
                                    zoom_to_route();
                                    wait = 0;
                                } else {
                                    wait = 1;
                                }

                                count++;
                                if (count > max_count) {
                                    wait = 0;
                                } else {
                                    Thread.sleep(400);
                                }
                            } catch (Exception e) {
                            }
                        }
                    }
                };
                zoom_to_route_001.start();

                //               try
                //               {
                //                  show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
                //               }
                //               catch (Exception e2)
                //               {
                //                  e2.printStackTrace();
                //               }

                try {
                    Navit.follow_button_on();
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            } else {
                // no home location set
                Message msg = progress_handler.obtainMessage();
                Bundle b = new Bundle();
                msg.what = 2; // long Toast message
                b.putString("text", Navit.get_text("No Home Location set")); //TRANS
                msg.setData(b);
                progress_handler.sendMessage(msg);
            }
        } else if (type == 4) {

            if (startup_intent != null) {
                // Log.e("Navit", "**7**A " + startup_intent.getAction() + System.currentTimeMillis() + " " + Navit.startup_intent_timestamp);
                if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L) {
                    Log.e("Navit", "**7**A " + startup_intent.getAction());
                    Log.e("Navit", "**7**D " + startup_intent.getDataString());
                    intent_data = startup_intent.getDataString();
                    try {
                        intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                    // we consumed the intent, so reset timestamp value to avoid double consuming of event
                    Navit.startup_intent_timestamp = 0L;

                    if (intent_data != null) {
                        // file:///mnt/sdcard/zanavi_pos_recording_347834278.gpx
                        String tmp1;
                        tmp1 = intent_data.split(":", 2)[1].substring(2);

                        Log.e("Navit", "**7**f=" + tmp1);

                        // convert gpx file ---------------------
                        convert_gpx_file_real(tmp1);
                    }
                }
            }
        } else if (type == 1) {
            if (startup_intent != null) {
                if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L) {
                    Log.e("Navit", "**2**A " + startup_intent.getAction());
                    Log.e("Navit", "**2**D " + startup_intent.getDataString());
                    intent_data = startup_intent.getDataString();
                    // we consumed the intent, so reset timestamp value to avoid double consuming of event
                    Navit.startup_intent_timestamp = 0L;

                    if (intent_data != null) {
                        // set position to middle of screen -----------------------
                        // set position to middle of screen -----------------------
                        // set position to middle of screen -----------------------
                        //                     Message msg67 = new Message();
                        //                     Bundle b67 = new Bundle();
                        //                     b67.putInt("Callback", 51);
                        //                     b67.putInt("x", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getWidth() / 2));
                        //                     b67.putInt("y", (int) (NavitGraphics.Global_dpi_factor * Navit.NG__map_main.view.getHeight() / 2));
                        //                     msg67.setData(b67);
                        //                     N_NavitGraphics.callback_handler.sendMessage(msg67);
                        // set position to middle of screen -----------------------
                        // set position to middle of screen -----------------------
                        // set position to middle of screen -----------------------
                    }
                } else {
                    Log.e("Navit", "timestamp for navigate_to expired! not using data");
                }
            }

            System.out.println("SUI:000a " + intent_data);

            if ((intent_data != null) && ((substring_without_ioobe(intent_data, 0, 18)
                    .equals("google.navigation:"))
                    || (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/"))
                    || (substring_without_ioobe(intent_data, 0, 24).equals("https://maps.google.com/")))) {

                System.out.println("SUI:000b");

                // better use regex later, but for now to test this feature its ok :-)
                // better use regex later, but for now to test this feature its ok :-)

                // g: google.navigation:///?ll=49.4086,17.4855&entry=w&opt=
                // d: google.navigation:q=blabla-strasse # (this happens when you are offline, or from contacts)
                // b: google.navigation:q=48.25676,16.643
                // a: google.navigation:ll=48.25676,16.643&q=blabla-strasse
                // e: google.navigation:ll=48.25676,16.643&title=blabla-strasse
                //    sample: -> google.navigation:ll=48.026096,16.023993&title=N%C3%B6stach+43%2C+2571+N%C3%B6stach&entry=w
                //            -> google.navigation:ll=48.014413,16.005579&title=Hainfelder+Stra%C3%9Fe+44%2C+2571%2C+Austria&entry=w
                // f: google.navigation:ll=48.25676,16.643&...
                // c: google.navigation:ll=48.25676,16.643
                // h: http://maps.google.com/?q=48.222210,16.387058&z=16
                // i: https://maps.google.com/?q=48.222210,16.387058&z=16
                // i:,h: https://maps.google.com/maps/place?ftid=0x476d07075e933fc5:0xccbeba7fe1e3dd36&q=48.222210,16.387058&ui=maps_mini
                //
                // ??!!new??!!: http://maps.google.com/?cid=10549738100504591748&hl=en&gl=gb

                String lat;
                String lon;
                String q;

                String temp1 = null;
                String temp2 = null;
                String temp3 = null;
                boolean parsable = false;
                boolean unparsable_info_box = true;
                try {
                    intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }

                // DEBUG
                // DEBUG
                // DEBUG
                // intent_data = "google.navigation:q=Wien Burggasse 27";
                // intent_data = "google.navigation:q=48.25676,16.643";
                // intent_data = "google.navigation:ll=48.25676,16.643&q=blabla-strasse";
                // intent_data = "google.navigation:ll=48.25676,16.643";
                // DEBUG
                // DEBUG
                // DEBUG

                try {
                    Log.e("Navit", "found DEBUG 1: " + intent_data.substring(0, 20));
                    Log.e("Navit", "found DEBUG 2: " + intent_data.substring(20, 22));
                    Log.e("Navit", "found DEBUG 3: " + intent_data.substring(20, 21));
                    Log.e("Navit", "found DEBUG 4: " + intent_data.split("&").length);
                    Log.e("Navit", "found DEBUG 4.1: yy"
                            + intent_data.split("&")[1].substring(0, 1).toLowerCase() + "yy");
                    Log.e("Navit", "found DEBUG 5: xx" + intent_data.split("&")[1] + "xx");
                } catch (Exception e) {
                    e.printStackTrace();
                }

                if (!Navit.NavitStartupAlreadySearching) {
                    if (intent_data.length() > 19) {
                        // if h: then show target
                        if (substring_without_ioobe(intent_data, 0, 23).equals("http://maps.google.com/")) {
                            Uri uri = Uri.parse(intent_data);
                            Log.e("Navit", "target found (h): " + uri.getQueryParameter("q"));
                            parsable = true;
                            intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
                        }
                        // if i: then show target
                        else if (substring_without_ioobe(intent_data, 0, 24)
                                .equals("https://maps.google.com/")) {
                            Uri uri = Uri.parse(intent_data);
                            Log.e("Navit", "target found (i): " + uri.getQueryParameter("q"));
                            parsable = true;
                            intent_data = "google.navigation:ll=" + uri.getQueryParameter("q") + "&q=Target";
                        }
                        // if d: then start target search
                        else if ((substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q="))
                                && ((!substring_without_ioobe(intent_data, 20, 21).equals('+'))
                                        && (!substring_without_ioobe(intent_data, 20, 21).equals('-'))
                                        && (!substring_without_ioobe(intent_data, 20, 22)
                                                .matches("[0-9][0-9]")))) {
                            Log.e("Navit", "target found (d): " + intent_data.split("q=", -1)[1]);
                            Navit.NavitStartupAlreadySearching = true;
                            start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
                            // dont use this here, already starting search, so set to "false"
                            parsable = false;
                            unparsable_info_box = false;
                        }
                        // if b: then remodel the input string to look like a:
                        else if (substring_without_ioobe(intent_data, 0, 20).equals("google.navigation:q=")) {
                            intent_data = "ll=" + intent_data.split("q=", -1)[1] + "&q=Target";
                            Log.e("Navit", "target found (b): " + intent_data);
                            parsable = true;
                        }
                        // if g: [google.navigation:///?ll=49.4086,17.4855&...] then remodel the input string to look like a:
                        else if (substring_without_ioobe(intent_data, 0, 25)
                                .equals("google.navigation:///?ll=")) {
                            intent_data = "google.navigation:ll="
                                    + intent_data.split("ll=", -1)[1].split("&", -1)[0] + "&q=Target";
                            Log.e("Navit", "target found (g): " + intent_data);
                            parsable = true;
                        }
                        // if e: then remodel the input string to look like a:
                        else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll="))
                                && (intent_data.split("&").length > 1)
                                && (substring_without_ioobe(intent_data.split("&")[1], 0, 1).toLowerCase()
                                        .equals("f"))) {
                            int idx = intent_data.indexOf("&");
                            intent_data = substring_without_ioobe(intent_data, 0, idx) + "&q=Target";
                            Log.e("Navit", "target found (e): " + intent_data);
                            parsable = true;
                        }
                        // if f: then remodel the input string to look like a:
                        else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll="))
                                && (intent_data.split("&").length > 1)) {
                            int idx = intent_data.indexOf("&");
                            intent_data = intent_data.substring(0, idx) + "&q=Target";
                            Log.e("Navit", "target found (f): " + intent_data);
                            parsable = true;
                        }
                        // already looks like a: just set flag
                        else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll="))
                                && (intent_data.split("&q=").length > 1)) {
                            // dummy, just set the flag
                            Log.e("Navit", "target found (a): " + intent_data);
                            Log.e("Navit", "target found (a): " + intent_data.split("&q=").length);
                            parsable = true;
                        }
                        // if c: then remodel the input string to look like a:
                        else if ((substring_without_ioobe(intent_data, 0, 21).equals("google.navigation:ll="))
                                && (intent_data.split("&q=").length < 2)) {

                            intent_data = intent_data + "&q=Target";
                            Log.e("Navit", "target found (c): " + intent_data);
                            parsable = true;
                        }
                    }
                } else {
                    Log.e("Navit", "already started search from startup intent");
                    parsable = false;
                    unparsable_info_box = false;
                }

                if (parsable) {
                    // now string should be in form --> a:
                    // now split the parts off
                    temp1 = intent_data.split("&q=", -1)[0];
                    try {
                        temp3 = temp1.split("ll=", -1)[1];
                        temp2 = intent_data.split("&q=", -1)[1];
                    } catch (Exception e) {
                        // java.lang.ArrayIndexOutOfBoundsException most likely
                        // so let's assume we dont have '&q=xxxx'
                        temp3 = temp1;
                    }

                    if (temp2 == null) {
                        // use some default name
                        temp2 = "Target";
                    }

                    lat = temp3.split(",", -1)[0];
                    lon = temp3.split(",", -1)[1];
                    q = temp2;
                    // is the "search name" url-encoded? i think so, lets url-decode it here
                    q = URLDecoder.decode(q);
                    // System.out.println();

                    Navit.remember_destination(q, lat, lon);
                    Navit.destination_set();

                    Message msg = new Message();
                    Bundle b = new Bundle();
                    b.putInt("Callback", 3);
                    b.putString("lat", lat);
                    b.putString("lon", lon);
                    b.putString("q", q);
                    msg.setData(b);
                    NavitGraphics.callback_handler.sendMessage(msg);

                    final Thread zoom_to_route_002 = new Thread() {
                        int wait = 1;
                        int count = 0;
                        int max_count = 60;

                        @Override
                        public void run() {
                            while (wait == 1) {
                                try {
                                    if ((NavitGraphics.navit_route_status == 17)
                                            || (NavitGraphics.navit_route_status == 33)) {
                                        zoom_to_route();
                                        wait = 0;
                                    } else {
                                        wait = 1;
                                    }

                                    count++;
                                    if (count > max_count) {
                                        wait = 0;
                                    } else {
                                        Thread.sleep(400);
                                    }
                                } catch (Exception e) {
                                }
                            }
                        }
                    };
                    zoom_to_route_002.start();

                    //                  try
                    //                  {
                    //                     Thread.sleep(400);
                    //                  }
                    //                  catch (InterruptedException e)
                    //                  {
                    //                  }
                    //
                    //                  //                  try
                    //                  //                  {
                    //                  //                     show_geo_on_screen(Float.parseFloat(lat), Float.parseFloat(lon));
                    //                  //                  }
                    //                  //                  catch (Exception e2)
                    //                  //                  {
                    //                  //                     e2.printStackTrace();
                    //                  //                  }

                    try {
                        Navit.follow_button_on();
                    } catch (Exception e2)

                    {
                        e2.printStackTrace();
                    }
                } else {
                    if (unparsable_info_box && !searchBoxShown) {
                        try {
                            searchBoxShown = true;
                            String searchString = intent_data.split("q=")[1];
                            searchString = searchString.split("&")[0];
                            searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
                            Log.e("Navit", "Search String :" + searchString);
                            executeSearch(searchString);
                        } catch (Exception e) {
                            // safety net
                            try {
                                Log.e("Navit", "problem with startup search 7 str=" + intent_data);
                            } catch (Exception e2) {
                                e2.printStackTrace();
                            }
                        }
                    }
                }
            } else if ((intent_data != null)
                    && (substring_without_ioobe(intent_data, 0, 10).equals("geo:0,0?q="))) {
                // g: geo:0,0?q=wien%20burggasse

                System.out.println("SUI:001");

                boolean parsable = false;
                boolean unparsable_info_box = true;
                try {
                    intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
                } catch (Exception e1) {
                    e1.printStackTrace();

                }

                System.out.println("SUI:002");

                if (!Navit.NavitStartupAlreadySearching) {
                    if (intent_data.length() > 10) {
                        // if g: then start target search
                        Log.e("Navit", "target found (g): " + intent_data.split("q=", -1)[1]);
                        Navit.NavitStartupAlreadySearching = true;
                        start_targetsearch_from_intent(intent_data.split("q=", -1)[1]);
                        // dont use this here, already starting search, so set to "false"
                        parsable = false;
                        unparsable_info_box = false;
                    }
                } else {
                    Log.e("Navit", "already started search from startup intent");
                    parsable = false;
                    unparsable_info_box = false;
                }

                if (unparsable_info_box && !searchBoxShown) {
                    try {
                        searchBoxShown = true;
                        String searchString = intent_data.split("q=")[1];
                        searchString = searchString.split("&")[0];
                        searchString = URLDecoder.decode(searchString); // decode the URL: e.g. %20 -> space
                        Log.e("Navit", "Search String :" + searchString);
                        executeSearch(searchString);
                    } catch (Exception e) {
                        // safety net
                        try {
                            Log.e("Navit", "problem with startup search 88 str=" + intent_data);
                        } catch (Exception e2) {
                            e2.printStackTrace();
                        }
                    }
                }

            } else if ((intent_data != null) && (substring_without_ioobe(intent_data, 0, 4).equals("geo:"))) {
                // g: geo:16.8,46.3?z=15

                System.out.println("SUI:002a");

                boolean parsable = false;
                boolean unparsable_info_box = true;

                String tmp1;
                String tmp2;
                String tmp3;
                float lat1 = 0;
                float lon1 = 0;
                int zoom1 = 15;

                try {
                    intent_data = java.net.URLDecoder.decode(intent_data, "UTF-8");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }

                if (!Navit.NavitStartupAlreadySearching) {
                    try {
                        tmp1 = intent_data.split(":", 2)[1];
                        tmp2 = tmp1.split("\\?", 2)[0];
                        tmp3 = tmp1.split("\\?", 2)[1];
                        lat1 = Float.parseFloat(tmp2.split(",", 2)[0]);
                        lon1 = Float.parseFloat(tmp2.split(",", 2)[1]);
                        zoom1 = Integer.parseInt(tmp3.split("z=", 2)[1]);
                        parsable = true;
                    } catch (Exception e4) {
                        e4.printStackTrace();
                    }
                }

                if (parsable) {
                    // geo: intent -> only show destination on map!

                    // set nice zoomlevel before we show destination
                    //                  int zoom_want = zoom1;
                    //                  //
                    //                  Message msg = new Message();
                    //                  Bundle b = new Bundle();
                    //                  b.putInt("Callback", 33);
                    //                  b.putString("s", Integer.toString(zoom_want));
                    //                  msg.setData(b);
                    //                  try
                    //                  {
                    //                     N_NavitGraphics.callback_handler.sendMessage(msg);
                    //                     Navit.GlobalScaleLevel = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL;
                    //                     if ((zoom_want > 8) && (zoom_want < 17))
                    //                     {
                    //                        Navit.GlobalScaleLevel = (int) (Math.pow(2, (18 - zoom_want)));
                    //                        System.out.println("GlobalScaleLevel=" + Navit.GlobalScaleLevel);
                    //                     }
                    //                  }
                    //                  catch (Exception e)
                    //                  {
                    //                     e.printStackTrace();
                    //                  }
                    //                  if (PREF_save_zoomlevel)
                    //                  {
                    //                     setPrefs_zoomlevel();
                    //                  }
                    // set nice zoomlevel before we show destination

                    try {
                        Navit.follow_button_off();
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }

                    show_geo_on_screen(lat1, lon1);
                    //                  final Thread zoom_to_route_003 = new Thread()
                    //                  {
                    //                     @Override
                    //                     public void run()
                    //                     {
                    //                        try
                    //                        {
                    //                           Thread.sleep(200);
                    //                           show_geo_on_screen(lat1, lon1);
                    //                        }
                    //                        catch (Exception e)
                    //                        {
                    //                        }
                    //                     }
                    //                  };
                    //                  zoom_to_route_003.start();

                }
            }
        }

        System.out.println("SUI:099 XX" + substring_without_ioobe(intent_data, 0, 10) + "XX");

        // clear intent
        startup_intent = null;
        // ------------------------  BIG LOOP  ------------------------
        // ------------------------  BIG LOOP  ------------------------
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("SUI:199");
    }

    // clear intent
    startup_intent = null;

    // hold all map drawing -----------
    Message msg = new Message();
    Bundle b = new Bundle();
    b.putInt("Callback", 69);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
    }
    // hold all map drawing -----------

    getPrefs();
    activatePrefs();
    sun_moon__mLastCalcSunMillis = -1L;

    push_pin_view = (ImageView) findViewById(R.id.bottom_slide_left_side);
    if (p.PREF_follow_gps) {
        push_pin_view.setImageResource(R.drawable.pin1_down);
    } else {
        push_pin_view.setImageResource(R.drawable.pin1_up);
    }

    // paint for bitmapdrawing on map
    if (p.PREF_use_anti_aliasing) {
        NavitGraphics.paint_for_map_display.setAntiAlias(true);
    } else {
        NavitGraphics.paint_for_map_display.setAntiAlias(false);
    }
    if (p.PREF_use_map_filtering) {
        NavitGraphics.paint_for_map_display.setFilterBitmap(true);
    } else {
        NavitGraphics.paint_for_map_display.setFilterBitmap(false);
    }

    // activate gps AFTER 3g-location
    NavitVehicle.turn_on_precise_provider();

    // allow all map drawing -----------
    msg = new Message();
    b = new Bundle();
    b.putInt("Callback", 70);
    msg.setData(b);
    try {
        NavitGraphics.callback_handler.sendMessage(msg);
    } catch (Exception e) {
    }
    // allow all map drawing -----------

    // --- disabled --- NavitVehicle.set_last_known_pos_fast_provider();

    try {
        //Simulate = new SimGPS(NavitVehicle.vehicle_handler_);
        //Simulate.start();
    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        watchmem = new WatchMem();
        watchmem.start();
    } catch (Exception e) {
        e.printStackTrace();
    }

    // ----- check if we have some index files downloaded -----

    if (api_version_int < 11) {
        if (Navit.have_maps_installed()) {
            if (Navit_maps_too_old) {
                TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
                no_maps_text.setText("\n\n\n" + Navit.get_text("Some Maps are too old!") + "\n"
                        + Navit.get_text("Please update your maps") + "\n\n");

                try {
                    NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
                    try {
                        NavitGraphics.no_maps_container.setActivated(true);
                    } catch (NoSuchMethodError e) {
                    }
                    NavitGraphics.no_maps_container.bringToFront();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                allow_use_index_search();
                if (Navit_index_on_but_no_idx_files) {
                    TextView no_maps_text = (TextView) this.findViewById(R.id.no_maps_text);
                    no_maps_text.setText("\n\n\n" + Navit.get_text("No Index for some Maps") + "\n"
                            + Navit.get_text("Please update your maps") + "\n\n");

                    try {
                        NavitGraphics.no_maps_container.setVisibility(View.VISIBLE);
                        try {
                            NavitGraphics.no_maps_container.setActivated(true);
                        } catch (NoSuchMethodError e) {
                        }
                        NavitGraphics.no_maps_container.bringToFront();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    try {
                        NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
                        try {
                            NavitGraphics.no_maps_container.setActivated(false);
                        } catch (NoSuchMethodError e) {
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    } else {
        try {
            NavitGraphics.no_maps_container.setVisibility(View.INVISIBLE);
            try {
                NavitGraphics.no_maps_container.setActivated(false);
            } catch (NoSuchMethodError e) {
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    // ----- check if we have some index files downloaded -----

    // ---- DEBUG ----
    // ---- DEBUG ----
    // ---- DEBUG ----
    try {
        if (!NavitVehicle.is_pos_recording) {
            if (p.PREF_enable_debug_write_gpx) {
                NavitVehicle.pos_recording_start();
                NavitVehicle.pos_recording_add(0, 0, 0, 0, 0, 0);
            }
        }
    } catch (Exception e) {
    }
    // ---- DEBUG ----
    // ---- DEBUG ----
    // ---- DEBUG ----

    // glSurfaceView.onResume();

    // if (Navit.METHOD_DEBUG) Navit.my_func_name(1);

    if (Navit.CIDEBUG == 1) {
        new Thread() {
            public void run() {
                try {
                    System.out.println("DR_run_all_yaml_tests --> want");

                    if (CIRUN == false) {
                        System.out.println("DR_run_all_yaml_tests --> do");
                        CIRUN = true;
                        Thread.sleep(20000); // 20 secs.
                        ZANaviDebugReceiver.DR_run_all_yaml_tests();
                    }
                } catch (Exception e) {
                }
            }
        }.start();
    }
}