I wanted to know if is it possible to hide the microphone button (speech-to-text) in Android Virtual Keyboard programatically.

I know I can disable this option through device settings, but I don't want the user to use this feature in my application independently of his/her settings. 
I mean i want to force this behaviour inside my app.

Thanks in advance,
Demian


Question: Unix C++: get time at a different zone
Answer: I have the following C code stashed away to deal with the problem.  Efficiency isn't the first word that springs to mind (two calls to setenv(), two calls to tzset()), but the standard C library doesn't make it easy to do better:

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;time.h&gt;
#include &lt;unistd.h&gt;

static void time_convert(time_t t0, char const *tz_value)
{
    char old_tz[64];
    strcpy(old_tz, getenv("TZ"));
    setenv("TZ", tz_value, 1);
    tzset();
    char new_tz[64];
    strcpy(new_tz, getenv("TZ"));
    char buffer[64];
    struct tm *lt = localtime(&amp;t0);
    strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", lt);
    setenv("TZ", old_tz, 1);
    tzset();
    printf("%ld = %s (TZ=%s)\n", (long)t0, buffer, new_tz);
}

int main(void)
{
    time_t t0 = time(0);
    char *tz = getenv("TZ");
    time_convert(t0, tz);
    time_convert(t0, "UTC0");
    time_convert(t0, "IST-5:30");
    time_convert(t0, "EST5");
    time_convert(t0, "EST5EDT");
    time_convert(t0, "PST8");
    time_convert(t0, "PST8PDT");
}


In your original code, you have to worry about normalizing the time structure after changing the hour offset.  You can do that with the mktime() function.  Here's a program based on the function in the question, which is pure C and avoids the problems of returning a pointer to a local variable (and the #define ending with a semi-colon):

#include &lt;assert.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

#define PST (-8)

extern int getSecondSystemTime(char *buffer, size_t buflen);

int getSecondSystemTime(char *buffer, size_t buflen)
{
    time_t rawtime = time(0);;
    struct tm *timeinfo;
    char t_buff[32];

    timeinfo = gmtime(&amp;rawtime);
    timeinfo-&gt;tm_hour = timeinfo-&gt;tm_hour + PST;

    time_t pst_time = mktime(timeinfo);
    assert(pst_time != (time_t)-1);
    int len = strftime(t_buff, sizeof(t_buff), "%Y-%m-%d %H:%M:%S", timeinfo);
    assert(len != 0);

    int rv = snprintf(buffer, buflen, "%ld = %s (%s)", (long)rawtime, t_buff, 
                      "Pacific Time (US &amp; Canada)");
    assert(rv &gt; 0);
    return rv;
}

int main(void)
{
    char buffer[128];

    getSecondSystemTime(buffer, sizeof(buffer));
    printf("%s\n", buffer);
    return(0);
}


Clearly, a better interface would pass the UTC time value and the time zone offset (in hours and minutes) as arguments.  Despite the fact that my computer runs in US/Pacific (or America/Los_Angeles) time zone by default, I tested with TZ set to various values (including US/Eastern, IST-05:30) and got the correct values out; I'm reasonably convinced based on past experience that the calculation is correct.

I have another program that attempts to dissect whether the -1 returned from mktime() is because of an error or because the converted time corresponds to (time_t)-1:

/* Attempt to determine whether time is really 1969-12-31 23:59:59 +00:00 */
static int unix_epoch_minus_one(const struct tm *lt)
{
    printf("tm_sec = %d\n", lt-&gt;tm_sec);
    if (lt-&gt;tm_sec != 59)
        return(0);
    printf("tm_min = %d\n", lt-&gt;tm_min);
    /* Accounts for time zones such as Newfoundland (-04:30), India (+05:30) and Nepal (+05:45) */
    if (lt-&gt;tm_min % 15 != 14)
        return(0);
    /* Years minus 1900 */
    printf("tm_year = %d\n", lt-&gt;tm_year);
    if (lt-&gt;tm_year != 69 &amp;&amp; lt-&gt;tm_year != 70)
        return(0);
    printf("tm_mday = %d\n", lt-&gt;tm_mday);
    if (lt-&gt;tm_mday != 31 &amp;&amp; lt-&gt;tm_mday != 1)
        return(0);
    /* Months 0..11 */
    printf("tm_mon = %d\n", lt-&gt;tm_mon);
    if (lt-&gt;tm_mon != 11 &amp;&amp; lt-&gt;tm_mon != 0)
        return(0);
    /* Pretend it is valid after all - though there is a small chance we are incorrect */
    return 1;
}