您好,我需要在手机中搜索并列出所有尝试启动Intent(Intent.ACTION_CALL)的应用程序,这些应用程序都支持它。我不知道是否有可能,我检查了Intent.createChooser()方法的实现,但我并不幸运。
我真正想做的是一个视图,用户可以在该视图中配置要执行的呼叫某人操作的应用程序。这就是为什么我需要搜索用户手机中支持Intent.ACTION_CALL的所有应用程序以在列表中显示它们的原因。在用户选择了所需的应用程序之后,我将管理用户何时拨打电话,启动他选择的应用程序。
谢谢
答案 0 :(得分:0)
尝试使用这段代码
pd = [ #This is the visual of the pyramid
[ 1 ], #[0][0] row and total col# ex [2][1] = 5
[ 2, 3 ], #[1][1]
[ 4, 5, 6, ], #[2][2]
[ 7, 8, 9, 10, ], #[3][3]
[ 11, 12, 13, 14, 15, ], #[4][4]
[ 16, 17, 18, 19, 20, 21, ], #[5][5]
]
x = 0 # represents left and right direction in pd -- adding goes right, subtracting goes left
y = 5 # represents up and down direction in pd -- adding goes down, subtracting goes up
lower_bound = 1 #used as lower bound in dice selection
upper_bound = 4 #used as upper bound in dice selection
move_counter = 0 #used to count the total number of moves made in game
print("Starting position: ",pd[y][x]) # The starting position used for debugging
start_position = pd[y][x] # The starting point of the game [y][x] up/down y, left/right x
# ---- loop begin ----
#while()
random_roll = random.randint(lower_bound, upper_bound) # Randomly selects a number from 1 to 4 to be used as fair die roll
print("Random Roll: " ,random_roll)
#--------------------------------pd bounds checking-------------------------------------------
if random_roll == 1 and (pd[y][x]) != 2 \
and (pd[y][x]) != 4 and (pd[y][x]) != 11 and (pd[y][x]) != 16:
#--------------------------------pd bounds checking-------------------------------------------
print('upper left')
# print('x: ', x, 'y:', y)
if pd[y][x] == 1:
print('Invalid Direction -- Move Count Increased')
move_counter += 1
else:
new_pos = pd[y-1][x-1]
y-=1
x-=1
#print('x: ', x, 'y:', y)
print('new pos: ' , new_pos)
start_position = new_pos
print('st pos', start_position)
move_counter += 1
#--------------------------------pd bounds checking-------------------------------------------
elif random_roll == 2 and (pd[y][x]) != 3 \
and (pd[y][x]) != 6 and (pd[y][x]) != 10 and (pd[y][x]) != 15 and (pd[y][x]) != 21:
# --------------------------------pd bounds checking-------------------------------------------
print('upper right')
#print('x: ', x, 'y:', y)
if pd[y][x] == 1:
print('Invalid Direction -- Move Count Increased')
move_counter += 1
else:
new_pos = pd[y-1][x]
y-=1
x+=1
# print('x: ', x, 'y:', y)
print('new pos: ' , new_pos)
start_position = new_pos
print('st pos', start_position)
move_counter += 1
#--------------------------------pd bounds checking-------------------------------------------
elif random_roll == 3 and (pd[y][x]) != 16 and (pd[y][x]) != 17 \
and (pd[y][x]) != 18 and (pd[y][x]) != 19 and (pd[y][x]) != 20 and (pd[y][x]) != 21:
# --------------------------------pd bounds checking-------------------------------------------
print(' down left')
#print('x: ', x, 'y:', y)
new_pos = pd[y+1][x]
x-=1
y+=1
# print('x: ', x, 'y:' , y)
print('new pos: ' , new_pos)
start_position = new_pos
print('st pos', start_position)
move_counter += 1
#--------------------------------pd bounds checking-------------------------------------------
elif random_roll == 4 and (pd[y][x]) != 16 and (pd[y][x]) != 17 \
and (pd[y][x]) != 18 and (pd[y][x]) != 19 and (pd[y][x]) != 20 and (pd[y][x]) != 21 :
# --------------------------------pd bounds checking-------------------------------------------
print('down right')
# print('x: ', x, 'y:', y)
new_pos = pd[y+1][x+1]
x+=1
y+=1
# print('x: ', x, 'y:', y)
print('new pos: ' , new_pos)
start_position = new_pos
print('st pos', start_position)
move_counter += 1
else:
print('Invalid Direction -- Move Count Increased')
start_position = pd[y][x]
print('st pos', start_position)
move_counter += 1
# ---- loop end ----
这将检查是否有可用的应用程序来完成此操作。